From a4a3668c455fe87f731803e4d0b3abfbc4f22198 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Fri, 16 Apr 2021 19:03:55 +0200 Subject: [PATCH] [Blazor] Adds support for specifying generic type constraints in Razor files (#31800) Adds support for specifying generic type constraints in the @typeparam directive. The constraints are specified after the identifier for the type parameter using the same syntax used in c#. For example: @typeparam TParameter where TParameter : Base, ISomeInterface, class, new() --- .../CodeGeneration/CodeWriterExtensions.cs | 20 ++- .../CodeGeneration/DefaultDocumentWriter.cs | 2 +- .../src/ComponentResources.resx | 6 + .../ComponentDocumentClassifierPass.cs | 6 +- .../Components/ComponentTypeParamDirective.cs | 42 ++++-- .../DirectiveDescriptorBuilderExtensions.cs | 19 ++- .../src/DirectiveTokenKind.cs | 5 +- .../DesignTimeDirectiveTargetExtension.cs | 41 +++++- .../src/Intermediate/TypeParameter.cs | 3 +- .../src/Legacy/CSharpCodeParser.cs | 64 ++++++++- .../src/Legacy/CSharpKeyword.cs | 3 +- .../Legacy/CSharpLanguageCharacteristics.cs | 3 +- .../src/Legacy/CSharpTokenizer.cs | 3 +- .../src/PublicAPI.Unshipped.txt | 5 + .../src/RazorDiagnosticFactory.cs | 20 +++ .../src/RazorLanguageVersion.cs | 6 +- .../src/RazorProjectEngine.cs | 8 +- .../src/Resources.resx | 6 + .../CodeGeneration/CSharpCodeWriterTest.cs | 4 +- .../DefaultDocumentWriterTest.cs | 50 +++++++- ...irectiveDescriptorBuilderExtensionsTest.cs | 16 ++- .../ComponentCodeGenerationTestBase.cs | 30 +++++ .../test/Legacy/RazorDirectivesTest.cs | 73 +++++++++++ .../test/RazorLanguageVersionTest.cs | 2 +- .../TestComponent.codegen.cs | 121 ++++++++++++++++++ .../TestComponent.ir.txt | 44 +++++++ .../TestComponent.mappings.txt | 59 +++++++++ .../TestComponent.codegen.cs | 66 ++++++++++ .../TestComponent.ir.txt | 21 +++ .../TestComponent.mappings.txt | 29 +++++ ...ansitionsInAttributeValue_Throws.stree.txt | 4 +- .../HandlesQuotesAfterTransition.stree.txt | 2 +- ...NotIdentifierStartOrParenOrBrace.stree.txt | 2 +- ...erTransitionInEmbeddedExpression.stree.txt | 2 +- ...sErrorIfNewlineFollowsTransition.stree.txt | 2 +- ...itionAndBlockStartInEmbeddedExpr.stree.txt | 2 +- ...deSpanIfEOFOccursAfterTransition.stree.txt | 2 +- ...nvalidCharacterFollowsTransition.stree.txt | 2 +- ...seBlockIgnoresSingleSlashAtStart.stree.txt | 2 +- ...licitExprDoesNotAcceptDotAfterAt.stree.txt | 2 +- ...SingleSpaceOrNewlineAtDesignTime.stree.txt | 2 +- ...ingleAtOutputsZeroLengthCodeSpan.stree.txt | 2 +- ...FileAndOutputsZeroLengthCodeSpan.stree.txt | 2 +- ...EmitsAtSignAsMarkupIfAtEndOfFile.stree.txt | 2 +- ...ansitionsInAttributeValue_Throws.stree.txt | 4 +- ...ConstraintIdentifierIsDifferent.cspans.txt | 8 ++ ...enConstraintIdentifierIsDifferent.diag.txt | 1 + ...nConstraintIdentifierIsDifferent.stree.txt | 27 ++++ ...WhenFirstTokenIsNotWhereKeyword.cspans.txt | 7 + ...orWhenFirstTokenIsNotWhereKeyword.diag.txt | 1 + ...rWhenFirstTokenIsNotWhereKeyword.stree.txt | 26 ++++ ...traintTokenWorksWhenAtEndOfFile.cspans.txt | 8 ++ ...straintTokenWorksWhenAtEndOfFile.stree.txt | 28 ++++ ...erstandsGenericConstraintsToken.cspans.txt | 9 ++ ...derstandsGenericConstraintsToken.stree.txt | 30 +++++ ...Descriptor_WorksWhenAtEndOfFile.cspans.txt | 8 ++ ...eDescriptor_WorksWhenAtEndOfFile.stree.txt | 28 ++++ .../CanHandleSymbolBoundAttributes1.stree.txt | 2 +- .../CanHandleSymbolBoundAttributes2.stree.txt | 2 +- .../CanHandleSymbolBoundAttributes3.stree.txt | 2 +- .../CanHandleSymbolBoundAttributes4.stree.txt | 2 +- ...orEmptyTagHelperBoundAttributes1.stree.txt | 2 +- ...rEmptyTagHelperBoundAttributes10.stree.txt | 2 +- ...rEmptyTagHelperBoundAttributes11.stree.txt | 4 +- ...rEmptyTagHelperBoundAttributes12.stree.txt | 2 +- ...rEmptyTagHelperBoundAttributes13.stree.txt | 8 +- ...rEmptyTagHelperBoundAttributes14.stree.txt | 12 +- ...orEmptyTagHelperBoundAttributes2.stree.txt | 2 +- ...orEmptyTagHelperBoundAttributes3.stree.txt | 2 +- ...orEmptyTagHelperBoundAttributes4.stree.txt | 4 +- ...orEmptyTagHelperBoundAttributes5.stree.txt | 4 +- ...orEmptyTagHelperBoundAttributes6.stree.txt | 4 +- ...orEmptyTagHelperBoundAttributes7.stree.txt | 2 +- ...orEmptyTagHelperBoundAttributes8.stree.txt | 2 +- ...orEmptyTagHelperBoundAttributes9.stree.txt | 4 +- ...ForNonStringTagHelperAttributes1.stree.txt | 2 +- ...orNonStringTagHelperAttributes10.stree.txt | 4 +- ...orNonStringTagHelperAttributes11.stree.txt | 16 +-- ...ForNonStringTagHelperAttributes2.stree.txt | 2 +- ...ForNonStringTagHelperAttributes3.stree.txt | 2 +- ...ForNonStringTagHelperAttributes4.stree.txt | 6 +- ...ForNonStringTagHelperAttributes7.stree.txt | 36 +++--- ...ForNonStringTagHelperAttributes8.stree.txt | 4 +- ...ForNonStringTagHelperAttributes9.stree.txt | 4 +- ...tes_ComponentDirectiveAttributes.stree.txt | 2 +- ...tandsMinimizedAttributes_Block12.stree.txt | 2 +- ...tandsMinimizedAttributes_Block14.stree.txt | 2 +- ...dsMinimizedAttributes_Document12.stree.txt | 2 +- ...dsMinimizedAttributes_Document14.stree.txt | 2 +- ...partNonStringTagHelperAttributes.stree.txt | 2 +- .../AllowsPrefixedTagHelpers11.stree.txt | 2 +- 91 files changed, 1010 insertions(+), 134 deletions(-) create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.codegen.cs create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.ir.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.mappings.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintErrorsWhenConstraintIdentifierIsDifferent.cspans.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintErrorsWhenConstraintIdentifierIsDifferent.diag.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintErrorsWhenConstraintIdentifierIsDifferent.stree.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintTokenProducesErrorWhenFirstTokenIsNotWhereKeyword.cspans.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintTokenProducesErrorWhenFirstTokenIsNotWhereKeyword.diag.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintTokenProducesErrorWhenFirstTokenIsNotWhereKeyword.stree.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintTokenWorksWhenAtEndOfFile.cspans.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintTokenWorksWhenAtEndOfFile.stree.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsGenericConstraintsToken.cspans.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsGenericConstraintsToken.stree.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_WorksWhenAtEndOfFile.cspans.txt create mode 100644 src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_WorksWhenAtEndOfFile.stree.txt diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/CodeWriterExtensions.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/CodeWriterExtensions.cs index 227f8d2ae3a4..52391af09061 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/CodeWriterExtensions.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/CodeWriterExtensions.cs @@ -297,7 +297,7 @@ public static CodeWriter WriteMethodInvocation(this CodeWriter writer, string me public static CodeWriter WriteMethodInvocation(this CodeWriter writer, string methodName, bool endLine, params string[] parameters) { - return + return WriteStartMethodInvocation(writer, methodName) .Write(string.Join(", ", parameters)) .WriteEndMethodInvocation(endLine); @@ -377,7 +377,7 @@ public static CSharpCodeWritingScope BuildClassDeclaration( string name, string baseType, IList interfaces, - IList typeParameters) + IList<(string name, string constraint)> typeParameters) { for (var i = 0; i < modifiers.Count; i++) { @@ -391,7 +391,7 @@ public static CSharpCodeWritingScope BuildClassDeclaration( if (typeParameters != null && typeParameters.Count > 0) { writer.Write("<"); - writer.Write(string.Join(", ", typeParameters)); + writer.Write(string.Join(", ", typeParameters.Select(tp => tp.name))); writer.Write(">"); } @@ -419,6 +419,18 @@ public static CSharpCodeWritingScope BuildClassDeclaration( } writer.WriteLine(); + if (typeParameters != null) + { + for (var i = 0; i < typeParameters.Count; i++) + { + var constraint = typeParameters[i].constraint; + if (constraint != null) + { + writer.Write(constraint); + writer.WriteLine(); + } + } + } return new CSharpCodeWritingScope(writer); } @@ -605,7 +617,7 @@ private class LinePragmaWriter : IDisposable private readonly string _sourceFilePath; public LinePragmaWriter( - CodeWriter writer, + CodeWriter writer, SourceSpan span, CodeRenderingContext context) { diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DefaultDocumentWriter.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DefaultDocumentWriter.cs index e23a3030e940..0c2d584e3487 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DefaultDocumentWriter.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/CodeGeneration/DefaultDocumentWriter.cs @@ -150,7 +150,7 @@ public override void VisitClassDeclaration(ClassDeclarationIntermediateNode node node.ClassName, node.BaseType, node.Interfaces, - node.TypeParameters.Select(p => p.ParameterName).ToArray())) + node.TypeParameters.Select(p => (p.ParameterName, p.Constraints)).ToArray())) { VisitDefault(node); } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx index cbadc7ee10de..86084bc5b020 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx @@ -216,6 +216,12 @@ Merges a collection of attributes into the current element or component. + + The constraints applied to the type parameter. + + + type parameter constraint + Declares a generic type parameter for the generated component class. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDocumentClassifierPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDocumentClassifierPass.cs index d1828ca044a2..6f7ef8ab3694 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDocumentClassifierPass.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDocumentClassifierPass.cs @@ -109,7 +109,11 @@ protected override void OnDocumentStructureCreated( continue; } - @class.TypeParameters.Add(new TypeParameter() { ParameterName = typeParamNode.Tokens.First().Content, }); + @class.TypeParameters.Add(new TypeParameter() + { + ParameterName = typeParamNode.Tokens.First().Content, + Constraints = typeParamNode.Tokens.Skip(1).FirstOrDefault()?.Content + }); } method.ReturnType = "void"; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentTypeParamDirective.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentTypeParamDirective.cs index d37f84a0df8c..ff513d1df68d 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentTypeParamDirective.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentTypeParamDirective.cs @@ -7,23 +7,45 @@ namespace Microsoft.AspNetCore.Razor.Language.Components { internal class ComponentTypeParamDirective { - public static readonly DirectiveDescriptor Directive = DirectiveDescriptor.CreateDirective( - "typeparam", - DirectiveKind.SingleLine, - builder => - { - builder.AddMemberToken(ComponentResources.TypeParamDirective_Token_Name, ComponentResources.TypeParamDirective_Token_Description); - builder.Usage = DirectiveUsage.FileScopedMultipleOccurring; - builder.Description = ComponentResources.TypeParamDirective_Description; - }); + public static DirectiveDescriptor Directive = null; - public static RazorProjectEngineBuilder Register(RazorProjectEngineBuilder builder) + public static RazorProjectEngineBuilder Register(RazorProjectEngineBuilder builder, bool supportConstraints) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } + if (Directive == null) + { + // Do nothing and assume the first registration wins. In real life this directive is only ever registered once. + if (supportConstraints) + { + Directive = DirectiveDescriptor.CreateDirective( + "typeparam", + DirectiveKind.SingleLine, + builder => + { + builder.AddMemberToken(ComponentResources.TypeParamDirective_Token_Name, ComponentResources.TypeParamDirective_Token_Description); + builder.AddOptionalGenericTypeConstraintToken(ComponentResources.TypeParamDirective_Constraint_Name, ComponentResources.TypeParamDirective_Constraint_Description); + builder.Usage = DirectiveUsage.FileScopedMultipleOccurring; + builder.Description = ComponentResources.TypeParamDirective_Description; + }); + } + else + { + Directive = DirectiveDescriptor.CreateDirective( + "typeparam", + DirectiveKind.SingleLine, + builder => + { + builder.AddMemberToken(ComponentResources.TypeParamDirective_Token_Name, ComponentResources.TypeParamDirective_Token_Description); + builder.Usage = DirectiveUsage.FileScopedMultipleOccurring; + builder.Description = ComponentResources.TypeParamDirective_Description; + }); + } + } + builder.AddDirective(Directive, FileKinds.Component, FileKinds.ComponentImport); return builder; } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DirectiveDescriptorBuilderExtensions.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DirectiveDescriptorBuilderExtensions.cs index 3e9c14b46f99..321e56b2ccd5 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DirectiveDescriptorBuilderExtensions.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DirectiveDescriptorBuilderExtensions.cs @@ -1,4 +1,4 @@ -// Copyright(c) .NET Foundation.All rights reserved. +// Copyright(c) .NET Foundation.All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -248,5 +248,22 @@ public static IDirectiveDescriptorBuilder AddOptionalAttributeToken(this IDirect return builder; } + + public static IDirectiveDescriptorBuilder AddOptionalGenericTypeConstraintToken(this IDirectiveDescriptorBuilder builder, string name, string description) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + builder.Tokens.Add( + DirectiveTokenDescriptor.CreateToken( + DirectiveTokenKind.GenericTypeConstraint, + optional: true, + name: name, + description: description)); + + return builder; + } } } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DirectiveTokenKind.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DirectiveTokenKind.cs index 88b214071c9e..e315df37f764 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DirectiveTokenKind.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/DirectiveTokenKind.cs @@ -1,4 +1,4 @@ -// Copyright(c) .NET Foundation.All rights reserved. +// Copyright(c) .NET Foundation.All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. namespace Microsoft.AspNetCore.Razor.Language @@ -11,5 +11,6 @@ public enum DirectiveTokenKind String, Attribute, Boolean, + GenericTypeConstraint, } -} \ No newline at end of file +} diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Extensions/DesignTimeDirectiveTargetExtension.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Extensions/DesignTimeDirectiveTargetExtension.cs index 6e5a87f47c46..dcb5e34b9d01 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Extensions/DesignTimeDirectiveTargetExtension.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Extensions/DesignTimeDirectiveTargetExtension.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -12,17 +12,17 @@ internal class DesignTimeDirectiveTargetExtension : IDesignTimeDirectiveTargetEx private const string DirectiveTokenHelperMethodName = "__RazorDirectiveTokenHelpers__"; private const string TypeHelper = "__typeHelper"; - public void WriteDesignTimeDirective(CodeRenderingContext context, DesignTimeDirectiveIntermediateNode node) + public void WriteDesignTimeDirective(CodeRenderingContext context, DesignTimeDirectiveIntermediateNode directiveNode) { context.CodeWriter .WriteLine("#pragma warning disable 219") .WriteLine($"private void {DirectiveTokenHelperMethodName}() {{"); - for (var i = 0; i < node.Children.Count; i++) + for (var i = 0; i < directiveNode.Children.Count; i++) { - if (node.Children[i] is DirectiveTokenIntermediateNode n) + if (directiveNode.Children[i] is DirectiveTokenIntermediateNode directiveTokenNode) { - WriteDesignTimeDirectiveToken(context, n); + WriteDesignTimeDirectiveToken(context, directiveNode, directiveTokenNode, currentIndex: i); } } @@ -31,7 +31,7 @@ public void WriteDesignTimeDirective(CodeRenderingContext context, DesignTimeDir .WriteLine("#pragma warning restore 219"); } - private void WriteDesignTimeDirectiveToken(CodeRenderingContext context, DirectiveTokenIntermediateNode node) + private void WriteDesignTimeDirectiveToken(CodeRenderingContext context, DesignTimeDirectiveIntermediateNode parent, DirectiveTokenIntermediateNode node, int currentIndex) { var tokenKind = node.DirectiveToken.Kind; if (!node.Source.HasValue || @@ -192,6 +192,35 @@ private void WriteDesignTimeDirectiveToken(CodeRenderingContext context, Directi context.CodeWriter.WriteLine(";"); } break; + case DirectiveTokenKind.GenericTypeConstraint: + // We generate a generic local function with a generic parameter using the + // same name and apply the constraints, like below. + // The two warnings that we disable are: + // * Hiding the class type parameter with the parameter on the method + // * The function is defined but not used. + // static void TypeConstraints_TParamName() where TParamName ...; + context.CodeWriter.WriteLine("#pragma warning disable CS0693"); + context.CodeWriter.WriteLine("#pragma warning disable CS8321"); + using (context.CodeWriter.BuildLinePragma(node.Source, context)) + { + // It's OK to do this since a GenericTypeParameterConstraint token is always preceded by a member token. + var genericTypeParamName = (DirectiveTokenIntermediateNode)parent.Children[currentIndex - 1]; + context.CodeWriter + .Write("void __TypeConstraints_") + .Write(genericTypeParamName.Content) + .Write("<") + .Write(genericTypeParamName.Content) + .Write(">() "); + + context.AddSourceMappingFor(node); + context.CodeWriter.Write(node.Content); + context.CodeWriter.WriteLine(); + context.CodeWriter.WriteLine("{"); + context.CodeWriter.WriteLine("}"); + context.CodeWriter.WriteLine("#pragma warning restore CS0693"); + context.CodeWriter.WriteLine("#pragma warning restore CS8321"); + } + break; } context.CodeWriter.CurrentIndent = originalIndent; } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Intermediate/TypeParameter.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Intermediate/TypeParameter.cs index 08f953e23aeb..1b2b71650f19 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Intermediate/TypeParameter.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Intermediate/TypeParameter.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. namespace Microsoft.AspNetCore.Razor.Language.Intermediate @@ -6,5 +6,6 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate public sealed class TypeParameter { public string ParameterName { get; set; } + public string Constraints { get; set; } } } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpCodeParser.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpCodeParser.cs index 510a89a511a7..7f967ea31fa2 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpCodeParser.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpCodeParser.cs @@ -66,6 +66,7 @@ internal class CSharpCodeParser : TokenizerBackedParser "using", "namespace", "class", + "where" }; private readonly ISet CurrentKeywords = new HashSet(DefaultKeywords); @@ -1306,6 +1307,15 @@ private void ParseExtensibleDirective(in SyntaxListBuilder buil // Even if an error was logged do not bail out early. If a directive was used incorrectly it doesn't mean it can't be parsed. ValidateDirectiveUsage(descriptor, directiveStart); + // Capture the last member for validating generic type constraints. + // Generic type parameters are described by a member token followed by a generic constraint token. + // The generic constraint token includes the 'where' keyword, the identifier it applies and the constraint list and is represented as a token list. + // For the directive to be valid we need to check that the identifier for the member token matches the identifier in the generic constraint token. + // Once we are parsing the constraint token we have lost "easy" access to the identifier for the member. To avoid having complex logic in the generic + // constraint token parsing code, we instead keep track of the last identifier we've seen on a member token and use that information to check the + // identifier for the constraint an emit a diagnostic in case they are not the same. + string lastSeenMemberIdentifier = null; + for (var i = 0; i < descriptor.Tokens.Count; i++) { if (!At(SyntaxKind.Whitespace) && @@ -1327,14 +1337,16 @@ private void ParseExtensibleDirective(in SyntaxListBuilder buil { AcceptWhile(IsSpacingTokenIncludingComments); + SpanContext.ChunkGenerator = SpanChunkGenerator.Null; + SpanContext.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.Whitespace; + if (tokenDescriptor.Kind == DirectiveTokenKind.Member || tokenDescriptor.Kind == DirectiveTokenKind.Namespace || tokenDescriptor.Kind == DirectiveTokenKind.Type || tokenDescriptor.Kind == DirectiveTokenKind.Attribute || + tokenDescriptor.Kind == DirectiveTokenKind.GenericTypeConstraint || tokenDescriptor.Kind == DirectiveTokenKind.Boolean) { - SpanContext.ChunkGenerator = SpanChunkGenerator.Null; - SpanContext.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.Whitespace; directiveBuilder.Add(OutputTokensAsStatementLiteral()); if (EndOfFile || At(SyntaxKind.NewLine)) @@ -1350,8 +1362,6 @@ private void ParseExtensibleDirective(in SyntaxListBuilder buil } else { - SpanContext.ChunkGenerator = SpanChunkGenerator.Null; - SpanContext.EditHandler.AcceptedCharacters = AcceptedCharactersInternal.Whitespace; directiveBuilder.Add(OutputAsMarkupEphemeralLiteral()); } } @@ -1400,6 +1410,7 @@ private void ParseExtensibleDirective(in SyntaxListBuilder buil case DirectiveTokenKind.Member: if (At(SyntaxKind.Identifier)) { + lastSeenMemberIdentifier = CurrentToken.Content; AcceptAndMoveNext(); } else @@ -1459,6 +1470,51 @@ private void ParseExtensibleDirective(in SyntaxListBuilder buil return; } + break; + case DirectiveTokenKind.GenericTypeConstraint: + if (At(SyntaxKind.Keyword) && + string.Equals(CurrentToken.Content, CSharpLanguageCharacteristics.GetKeyword(CSharpKeyword.Where), StringComparison.Ordinal)) + { + // Consume the 'where' keyword plus any aditional whitespace + AcceptAndMoveNext(); + AcceptWhile(SyntaxKind.Whitespace); + // Check that the type name matches the type name before the where clause. + // Find a better way to do this + if (!string.Equals(CurrentToken.Content, lastSeenMemberIdentifier, StringComparison.Ordinal)) + { + // @typeparam TKey where TValue : ... + // The type parameter in the generic type constraint 'TValue' does not match the type parameter 'TKey' defined in the directive '@typeparam'. + Context.ErrorSink.OnError( + RazorDiagnosticFactory.CreateParsing_GenericTypeParameterIdentifierMismatch( + new SourceSpan(CurrentStart, CurrentToken.Content.Length), descriptor.Directive, CurrentToken.Content, lastSeenMemberIdentifier)); + builder.Add(BuildDirective()); + return; + } + else + { + while (!At(SyntaxKind.NewLine)) + { + AcceptAndMoveNext(); + if (EndOfFile) + { + // We've reached the end of the file, which is unusual but can happen, for example if we start typing in a new file. + break; + } + } + } + } + else + { + Context.ErrorSink.OnError( + RazorDiagnosticFactory.CreateParsing_UnexpectedIdentifier( + new SourceSpan(CurrentStart, CurrentToken.Content.Length), + CurrentToken.Content, + CSharpLanguageCharacteristics.GetKeyword(CSharpKeyword.Where))); + + builder.Add(BuildDirective()); + return; + } + break; } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpKeyword.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpKeyword.cs index b37807377ba1..f1ba9911d2d0 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpKeyword.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpKeyword.cs @@ -83,6 +83,7 @@ internal enum CSharpKeyword Break, Checked, Namespace, - When + When, + Where } } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpLanguageCharacteristics.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpLanguageCharacteristics.cs index febc9f649312..50a07886a687 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpLanguageCharacteristics.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpLanguageCharacteristics.cs @@ -145,6 +145,7 @@ internal class CSharpLanguageCharacteristics : LanguageCharacteristics bool Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeWriter.TabSize.get -> int +Microsoft.AspNetCore.Razor.Language.DirectiveTokenKind.GenericTypeConstraint = 6 -> Microsoft.AspNetCore.Razor.Language.DirectiveTokenKind Microsoft.AspNetCore.Razor.Language.Intermediate.CascadingGenericTypeParameter Microsoft.AspNetCore.Razor.Language.Intermediate.CascadingGenericTypeParameter.CascadingGenericTypeParameter() -> void ~Microsoft.AspNetCore.Razor.Language.CodeGeneration.CodeWriter.CodeWriter(string newLine, Microsoft.AspNetCore.Razor.Language.RazorCodeGenerationOptions options) -> void @@ -13,4 +14,8 @@ Microsoft.AspNetCore.Razor.Language.Intermediate.CascadingGenericTypeParameter.C ~Microsoft.AspNetCore.Razor.Language.Intermediate.ComponentTypeInferenceMethodIntermediateNode.ReceivesCascadingGenericTypes.set -> void abstract Microsoft.AspNetCore.Razor.Language.RazorConfiguration.UseConsolidatedMvcViews.get -> bool *REMOVED*~static Microsoft.AspNetCore.Razor.Language.RazorConfiguration.Create(Microsoft.AspNetCore.Razor.Language.RazorLanguageVersion languageVersion, string configurationName, System.Collections.Generic.IEnumerable extensions) -> Microsoft.AspNetCore.Razor.Language.RazorConfiguration +~Microsoft.AspNetCore.Razor.Language.Intermediate.TypeParameter.Constraints.get -> string +~Microsoft.AspNetCore.Razor.Language.Intermediate.TypeParameter.Constraints.set -> void +~static Microsoft.AspNetCore.Razor.Language.DirectiveDescriptorBuilderExtensions.AddOptionalGenericTypeConstraintToken(this Microsoft.AspNetCore.Razor.Language.IDirectiveDescriptorBuilder builder, string name, string description) -> Microsoft.AspNetCore.Razor.Language.IDirectiveDescriptorBuilder ~static Microsoft.AspNetCore.Razor.Language.RazorConfiguration.Create(Microsoft.AspNetCore.Razor.Language.RazorLanguageVersion languageVersion, string configurationName, System.Collections.Generic.IEnumerable extensions, bool useConsolidatedMvcViews = false) -> Microsoft.AspNetCore.Razor.Language.RazorConfiguration +~static readonly Microsoft.AspNetCore.Razor.Language.RazorLanguageVersion.Version_6_0 -> Microsoft.AspNetCore.Razor.Language.RazorLanguageVersion diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorDiagnosticFactory.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorDiagnosticFactory.cs index 9bef04b5bc24..d88879c15960 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorDiagnosticFactory.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorDiagnosticFactory.cs @@ -436,6 +436,26 @@ public static RazorDiagnostic CreateParsing_DirectiveExpectsBooleanLiteral(Sourc { return RazorDiagnostic.Create(Parsing_DirectiveExpectsBooleanLiteral, location, directiveName); } + + internal static readonly RazorDiagnosticDescriptor Parsing_GenericTypeParameterIdentifierMismatch = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1039", + () => Resources.DirectiveGenericTypeParameterIdentifierMismatch, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_GenericTypeParameterIdentifierMismatch(SourceSpan location, string directiveName, string constraintIdentifier, string originalMember) + { + return RazorDiagnostic.Create(Parsing_GenericTypeParameterIdentifierMismatch, location, directiveName, constraintIdentifier, originalMember); + } + + internal static readonly RazorDiagnosticDescriptor Parsing_UnexpectedIdentifier = + new RazorDiagnosticDescriptor( + $"{DiagnosticPrefix}1040", + () => Resources.ParseError_Unexpected_Identifier_At_Position, + RazorDiagnosticSeverity.Error); + public static RazorDiagnostic CreateParsing_UnexpectedIdentifier(SourceSpan location, string content, params string [] options) + { + return RazorDiagnostic.Create(Parsing_UnexpectedIdentifier, location, content, string.Join(", ", options)); + } #endregion #region Semantic Errors diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorLanguageVersion.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorLanguageVersion.cs index 7913dac29bc2..f2e00b3f9e9e 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorLanguageVersion.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorLanguageVersion.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -22,7 +22,9 @@ public sealed class RazorLanguageVersion : IEquatable, ICo public static readonly RazorLanguageVersion Version_5_0 = new RazorLanguageVersion(5, 0); - public static readonly RazorLanguageVersion Latest = Version_5_0; + public static readonly RazorLanguageVersion Version_6_0 = new RazorLanguageVersion(6, 0); + + public static readonly RazorLanguageVersion Latest = Version_6_0; public static readonly RazorLanguageVersion Experimental = new RazorLanguageVersion(1337, 1337); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorProjectEngine.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorProjectEngine.cs index 9d074110dc2a..2b2e79923d12 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorProjectEngine.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorProjectEngine.cs @@ -221,7 +221,13 @@ private static void AddComponentFeatures(RazorProjectEngineBuilder builder, Razo ComponentInjectDirective.Register(builder); ComponentLayoutDirective.Register(builder); ComponentPageDirective.Register(builder); - ComponentTypeParamDirective.Register(builder); + + // Unconditionally enable the feature for the time being until we flow the SDK with the flow version + // into the repository. + ComponentTypeParamDirective.Register( + builder, + supportConstraints: true); + //supportConstraints: razorLanguageVersion.CompareTo(RazorLanguageVersion.Version_6_0) >= 0); if (razorLanguageVersion.CompareTo(RazorLanguageVersion.Version_5_0) >= 0) { diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Resources.resx b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Resources.resx index a6fe1ab23554..8fa60e30c6e6 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Resources.resx +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Resources.resx @@ -565,4 +565,10 @@ @import rules are not supported within scoped CSS files because the loading order would be undefined. @import may only be placed in non-scoped CSS files. + + The type parameter in the generic type constraint '{1}' does not match the type parameter '{2}' defined in the directive '{0}'. + + + '{0}' is not valid in this position. Valid options are '{1}' + \ No newline at end of file diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/CodeGeneration/CSharpCodeWriterTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/CodeGeneration/CSharpCodeWriterTest.cs index 88f4447eda61..9f5e7a0f10c5 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/CodeGeneration/CSharpCodeWriterTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/CodeGeneration/CSharpCodeWriterTest.cs @@ -373,7 +373,7 @@ public void CSharpCodeWriter_RespectTabSetting() var writer = new CodeWriter(Environment.NewLine, options); // Act - writer.BuildClassDeclaration(Array.Empty(), "C", "", Array.Empty(), Array.Empty()); + writer.BuildClassDeclaration(Array.Empty(), "C", "", Array.Empty(), Array.Empty<(string,string)>()); writer.WriteField(Array.Empty(), Array.Empty(), "int", "f"); // Assert @@ -394,7 +394,7 @@ public void CSharpCodeWriter_RespectSpaceSetting() var writer = new CodeWriter(Environment.NewLine, options); // Act - writer.BuildClassDeclaration(Array.Empty(), "C", "", Array.Empty(), Array.Empty()); + writer.BuildClassDeclaration(Array.Empty(), "C", "", Array.Empty(), Array.Empty<(string, string)>()); writer.WriteField(Array.Empty(), Array.Empty(), "int", "f"); // Assert diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/CodeGeneration/DefaultDocumentWriterTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/CodeGeneration/DefaultDocumentWriterTest.cs index 3537eea4f61a..72271025d8f1 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/CodeGeneration/DefaultDocumentWriterTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/CodeGeneration/DefaultDocumentWriterTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -250,6 +250,54 @@ internal class TestClass : TestBase, IFoo, IBar ignoreLineEndingDifferences: true); } + [Fact] + public void WriteDocument_WritesClass_ConstrainedGenericTypeParameters() + { + // Arrange + var document = new DocumentIntermediateNode(); + var builder = IntermediateNodeBuilder.Create(document); + builder.Add(new ClassDeclarationIntermediateNode() + { + Modifiers = + { + "internal" + }, + BaseType = "TestBase", + Interfaces = new List { "IFoo", "IBar", }, + TypeParameters = new List + { + new TypeParameter() { ParameterName = "TKey", Constraints = "where TKey : class" }, + new TypeParameter() { ParameterName = "TValue", Constraints = "where TValue : class" }, + }, + ClassName = "TestClass", + }); + + var codeDocument = TestRazorCodeDocument.CreateEmpty(); + var options = RazorCodeGenerationOptions.CreateDefault(); + + var target = CodeTarget.CreateDefault(codeDocument, options); + var writer = new DefaultDocumentWriter(target, options); + + // Act + var result = writer.WriteDocument(codeDocument, document); + + // Assert + var csharp = result.GeneratedCode; + Assert.Equal( +@"#pragma checksum ""test.cshtml"" ""{ff1816ec-aa5e-4d10-87f7-6f4963833460}"" ""da39a3ee5e6b4b0d3255bfef95601890afd80709"" +// +#pragma warning disable 1591 +internal class TestClass : TestBase, IFoo, IBar +where TKey : class +where TValue : class +{ +} +#pragma warning restore 1591 +", + csharp, + ignoreLineEndingDifferences: true); + } + [Fact] public void WriteDocument_WritesMethod() { diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DirectiveDescriptorBuilderExtensionsTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DirectiveDescriptorBuilderExtensionsTest.cs index 6e78ea1eec62..6bc388d93e4f 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DirectiveDescriptorBuilderExtensionsTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/DirectiveDescriptorBuilderExtensionsTest.cs @@ -1,4 +1,4 @@ -// Copyright(c) .NET Foundation.All rights reserved. +// Copyright(c) .NET Foundation.All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Xunit; @@ -146,5 +146,19 @@ public void AddOptionalAttributeToken_AddsToken() Assert.Null(token.Name); Assert.Null(token.Description); } + + [Fact] + public void AddOptionalGenericTypeConstraintToken_AddsToken() + { + // Arrange & Act + var descriptor = DirectiveDescriptor.CreateDirective("custom", DirectiveKind.SingleLine, b => b.AddOptionalGenericTypeConstraintToken("Name", "Description")); + + // Assert + var token = Assert.Single(descriptor.Tokens); + Assert.Equal(DirectiveTokenKind.GenericTypeConstraint, token.Kind); + Assert.True(token.Optional); + Assert.Equal("Name", token.Name); + Assert.Equal("Description", token.Description); + } } } diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index c06fc20f3d1a..c25d030ef099 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -211,6 +211,36 @@ public void ComponentWithTypeParameters() @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 ComponentWithConstrainedTypeParameters() + { + // Arrange + + // Act + var generated = CompileToCSharp(@" +@using Microsoft.AspNetCore.Components; +@typeparam TItem1 where TItem1 : class +@typeparam TItem2 where TItem2 : struct +

Item1

@foreach (var item2 in Items2) { diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/RazorDirectivesTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/RazorDirectivesTest.cs index 946fea9b51af..e70766d8382e 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/RazorDirectivesTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/Legacy/RazorDirectivesTest.cs @@ -907,6 +907,79 @@ public void Directives_ReservedWordInsideCodeBlock() ParseDocumentTest("@{ class }"); } + [Fact] + public void DirectiveDescriptor_UnderstandsGenericConstraintsToken() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => { + b.AddMemberToken(); + b.AddOptionalGenericTypeConstraintToken("name", "description"); + }); + + // Act & Assert + ParseDocumentTest(@" +@custom TSomething where TSomething : class +", + new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_GenericConstraintTokenWorksWhenAtEndOfFile() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => { + b.AddMemberToken(); + b.AddOptionalGenericTypeConstraintToken("name", "description"); + }); + + // Act & Assert + ParseDocumentTest(@" +@custom TSomething where TSomething : class", + directives: new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_GenericConstraintTokenProducesErrorWhenFirstTokenIsNotWhereKeyword() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => { + b.AddMemberToken(); + b.AddOptionalGenericTypeConstraintToken("name", "description"); + }); + + // Act & Assert + ParseDocumentTest(@" +@custom TSomething maybe TSomething : class", + directives: new[] { descriptor }); + } + + [Fact] + public void DirectiveDescriptor_GenericConstraintErrorsWhenConstraintIdentifierIsDifferent() + { + // Arrange + var descriptor = DirectiveDescriptor.CreateDirective( + "custom", + DirectiveKind.SingleLine, + b => { + b.AddMemberToken(); + b.AddOptionalGenericTypeConstraintToken("name", "description"); + }); + + // Act & Assert + ParseDocumentTest(@" +@custom TSomething where TElse : class", + directives: new[] { descriptor }); + } + [Fact] public void DirectiveDescriptor_UnderstandsAttributeTokens() { diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs index 4542300aac43..9eb3bc526c33 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/RazorLanguageVersionTest.cs @@ -118,7 +118,7 @@ public void TryParseLatest() // Assert Assert.True(result); - Assert.Same(RazorLanguageVersion.Version_5_0, version); + Assert.Same(RazorLanguageVersion.Version_6_0, version); } [Fact] diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.codegen.cs new file mode 100644 index 000000000000..2389f9b83f94 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.codegen.cs @@ -0,0 +1,121 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +using Microsoft.AspNetCore.Components; + +#line default +#line hidden +#nullable disable + public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + where TItem1 : class + where TItem2 : struct + { + #pragma warning disable 219 + private void __RazorDirectiveTokenHelpers__() { + ((System.Action)(() => { +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" +global::System.Object TItem1 = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#pragma warning disable CS0693 +#pragma warning disable CS8321 +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" +void __TypeConstraints_TItem1() where TItem1 : class +{ +} +#pragma warning restore CS0693 +#pragma warning restore CS8321 + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" +global::System.Object TItem2 = null!; + +#line default +#line hidden +#nullable disable + } + ))(); + ((System.Action)(() => { +#pragma warning disable CS0693 +#pragma warning disable CS8321 +#nullable restore +#line 3 "x:\dir\subdir\Test\TestComponent.cshtml" +void __TypeConstraints_TItem2() where TItem2 : struct +{ +} +#pragma warning restore CS0693 +#pragma warning restore CS8321 + +#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) + { +#nullable restore +#line 6 "x:\dir\subdir\Test\TestComponent.cshtml" + foreach (var item2 in Items2) +{ + + +#line default +#line hidden +#nullable disable +#nullable restore +#line 9 "x:\dir\subdir\Test\TestComponent.cshtml" +__o = ChildContent(item2); + +#line default +#line hidden +#nullable disable +#nullable restore +#line 10 "x:\dir\subdir\Test\TestComponent.cshtml" + +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 12 "x:\dir\subdir\Test\TestComponent.cshtml" + + [Parameter] public TItem1 Item1 { get; set; } + [Parameter] public List Items2 { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.ir.txt new file mode 100644 index 000000000000..7a154d09616b --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.ir.txt @@ -0,0 +1,44 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [12] ) - System + UsingDirective - (18:2,1 [32] ) - System.Collections.Generic + UsingDirective - (53:3,1 [17] ) - System.Linq + UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks + UsingDirective - (1:0,1 [38] x:\dir\subdir\Test\TestComponent.cshtml) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - - TItem1, TItem2 + DesignTimeDirective - + DirectiveToken - (52:1,11 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem1 + DirectiveToken - (59:1,18 [20] x:\dir\subdir\Test\TestComponent.cshtml) - where TItem1 : class + DirectiveToken - (92:2,11 [6] x:\dir\subdir\Test\TestComponent.cshtml) - TItem2 + DirectiveToken - (99:2,18 [21] x:\dir\subdir\Test\TestComponent.cshtml) - where TItem2 : struct + 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 + HtmlContent - (39:0,39 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (39:0,39 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlContent - (122:3,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (122:3,0 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + MarkupElement - (124:4,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1 + HtmlContent - (128:4,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (128:4,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Item1 + HtmlContent - (138:4,14 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (138:4,14 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (141:5,1 [38] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (141:5,1 [38] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - foreach (var item2 in Items2)\n{\n + MarkupElement - (179:7,4 [40] x:\dir\subdir\Test\TestComponent.cshtml) - p + HtmlContent - (182:7,7 [6] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (182:7,7 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpExpression - (189:8,5 [19] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (189:8,5 [19] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ChildContent(item2) + HtmlContent - (208:8,24 [7] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (208:8,24 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Html - ;\n + CSharpCode - (219:9,8 [3] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (219:9,8 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n} + HtmlContent - (222:10,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (222:10,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (231:11,7 [185] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (231:11,7 [185] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n [Parameter] public TItem1 Item1 { get; set; }\n [Parameter] public List Items2 { get; set; }\n [Parameter] public RenderFragment ChildContent { get; set; }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.mappings.txt new file mode 100644 index 000000000000..e23ccef64ac8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.mappings.txt @@ -0,0 +1,59 @@ +Source Location: (1:0,1 [38] x:\dir\subdir\Test\TestComponent.cshtml) +|using Microsoft.AspNetCore.Components;| +Generated Location: (276:11,0 [38] ) +|using Microsoft.AspNetCore.Components;| + +Source Location: (52:1,11 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|TItem1| +Generated Location: (750:25,22 [6] ) +|TItem1| + +Source Location: (59:1,18 [20] x:\dir\subdir\Test\TestComponent.cshtml) +|where TItem1 : class| +Generated Location: (1051:37,40 [20] ) +|where TItem1 : class| + +Source Location: (92:2,11 [6] x:\dir\subdir\Test\TestComponent.cshtml) +|TItem2| +Generated Location: (1345:51,22 [6] ) +|TItem2| + +Source Location: (99:2,18 [21] x:\dir\subdir\Test\TestComponent.cshtml) +|where TItem2 : struct| +Generated Location: (1646:63,40 [21] ) +|where TItem2 : struct| + +Source Location: (141:5,1 [38] x:\dir\subdir\Test\TestComponent.cshtml) +|foreach (var item2 in Items2) +{ + | +Generated Location: (2229:84,1 [38] ) +|foreach (var item2 in Items2) +{ + | + +Source Location: (189:8,5 [19] x:\dir\subdir\Test\TestComponent.cshtml) +|ChildContent(item2)| +Generated Location: (2395:93,6 [19] ) +|ChildContent(item2)| + +Source Location: (219:9,8 [3] x:\dir\subdir\Test\TestComponent.cshtml) +| +}| +Generated Location: (2546:100,8 [3] ) +| +}| + +Source Location: (231:11,7 [185] x:\dir\subdir\Test\TestComponent.cshtml) +| + [Parameter] public TItem1 Item1 { get; set; } + [Parameter] public List Items2 { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } +| +Generated Location: (2728:110,7 [185] ) +| + [Parameter] public TItem1 Item1 { get; set; } + [Parameter] public List Items2 { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } +| + diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.codegen.cs new file mode 100644 index 000000000000..ad841383def5 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.codegen.cs @@ -0,0 +1,66 @@ +// +#pragma warning disable 1591 +namespace Test +{ + #line hidden + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; +#nullable restore +#line 1 "x:\dir\subdir\Test\TestComponent.cshtml" +using Microsoft.AspNetCore.Components; + +#line default +#line hidden +#nullable disable + public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBase + where TItem1 : class + where TItem2 : struct + { + #pragma warning disable 1998 + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) + { + __builder.AddMarkupContent(0, "

Item1

"); +#nullable restore +#line 6 "x:\dir\subdir\Test\TestComponent.cshtml" + foreach (var item2 in Items2) +{ + +#line default +#line hidden +#nullable disable + __builder.OpenElement(1, "p"); + __builder.AddContent(2, +#nullable restore +#line 9 "x:\dir\subdir\Test\TestComponent.cshtml" + ChildContent(item2) + +#line default +#line hidden +#nullable disable + ); + __builder.AddMarkupContent(3, ";\r\n "); + __builder.CloseElement(); +#nullable restore +#line 11 "x:\dir\subdir\Test\TestComponent.cshtml" +} + +#line default +#line hidden +#nullable disable + } + #pragma warning restore 1998 +#nullable restore +#line 12 "x:\dir\subdir\Test\TestComponent.cshtml" + + [Parameter] public TItem1 Item1 { get; set; } + [Parameter] public List Items2 { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } + +#line default +#line hidden +#nullable disable + } +} +#pragma warning restore 1591 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.ir.txt new file mode 100644 index 000000000000..335b2b246d8d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.ir.txt @@ -0,0 +1,21 @@ +Document - + NamespaceDeclaration - - Test + UsingDirective - (3:1,1 [14] ) - System + UsingDirective - (18:2,1 [34] ) - System.Collections.Generic + UsingDirective - (53:3,1 [19] ) - System.Linq + UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks + UsingDirective - (1:0,1 [40] x:\dir\subdir\Test\TestComponent.cshtml) - Microsoft.AspNetCore.Components + ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - - TItem1, TItem2 + MethodDeclaration - - protected override - void - BuildRenderTree + MarkupBlock - -

Item1

+ CSharpCode - (141:5,1 [34] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (141:5,1 [34] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - foreach (var item2 in Items2)\n{\n + MarkupElement - (179:7,4 [40] x:\dir\subdir\Test\TestComponent.cshtml) - p + CSharpExpression - (189:8,5 [19] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (189:8,5 [19] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - ChildContent(item2) + HtmlContent - (208:8,24 [7] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (208:8,24 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Html - ;\n + CSharpCode - (221:10,0 [3] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (221:10,0 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - }\n + CSharpCode - (231:11,7 [185] x:\dir\subdir\Test\TestComponent.cshtml) + LazyIntermediateToken - (231:11,7 [185] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n [Parameter] public TItem1 Item1 { get; set; }\n [Parameter] public List Items2 { get; set; }\n [Parameter] public RenderFragment ChildContent { get; set; }\n diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.mappings.txt new file mode 100644 index 000000000000..243bbbe5303e --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/ComponentWithConstrainedTypeParameters/TestComponent.mappings.txt @@ -0,0 +1,29 @@ +Source Location: (141:5,1 [34] x:\dir\subdir\Test\TestComponent.cshtml) +|foreach (var item2 in Items2) +{ +| +Generated Location: (832:26,1 [34] ) +|foreach (var item2 in Items2) +{ +| + +Source Location: (221:10,0 [3] x:\dir\subdir\Test\TestComponent.cshtml) +|} +| +Generated Location: (1327:48,0 [3] ) +|} +| + +Source Location: (231:11,7 [185] x:\dir\subdir\Test\TestComponent.cshtml) +| + [Parameter] public TItem1 Item1 { get; set; } + [Parameter] public List Items2 { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } +| +Generated Location: (1507:57,7 [185] ) +| + [Parameter] public TItem1 Item1 { get; set; } + [Parameter] public List Items2 { get; set; } + [Parameter] public RenderFragment ChildContent { get; set; } +| + 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 index b869f2663202..92dd67f994c2 100644 --- 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 @@ -32,7 +32,7 @@ RazorDocument - [0..21)::21 - [@{}] Transition;[@]; CSharpImplicitExpressionBody - [14..14)::0 CSharpCodeBlock - [14..14)::0 - CSharpExpressionLiteral - [14..14)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + CSharpExpressionLiteral - [14..14)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 Marker;[]; MarkupDynamicAttributeValue - [14..16)::2 - [ @] MarkupTextLiteral - [14..15)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any @@ -44,7 +44,7 @@ RazorDocument - [0..21)::21 - [@{}] Transition;[@]; CSharpImplicitExpressionBody - [16..16)::0 CSharpCodeBlock - [16..16)::0 - CSharpExpressionLiteral - [16..16)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + CSharpExpressionLiteral - [16..16)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 Marker;[]; MarkupTextLiteral - [16..17)::1 - ['] - Gen - SpanEditHandler;Accepts:Any SingleQuote;[']; 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 index 585e50aec9f0..4abc1a1b9801 100644 --- 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 @@ -8,7 +8,7 @@ RazorDocument - [0..2)::2 - [@"] Transition;[@]; CSharpImplicitExpressionBody - [1..1)::0 CSharpCodeBlock - [1..1)::0 - CSharpExpressionLiteral - [1..1)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + CSharpExpressionLiteral - [1..1)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 Marker;[]; MarkupTextLiteral - [1..2)::1 - ["] - Gen - SpanEditHandler;Accepts:Any DoubleQuote;["]; 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 index 80bf05811cb9..5c2408197a86 100644 --- 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 @@ -8,7 +8,7 @@ RazorDocument - [0..4)::4 - [@!!!] Transition;[@]; CSharpImplicitExpressionBody - [1..1)::0 CSharpCodeBlock - [1..1)::0 - CSharpExpressionLiteral - [1..1)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + CSharpExpressionLiteral - [1..1)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 Marker;[]; MarkupTextLiteral - [1..4)::3 - [!!!] - Gen - SpanEditHandler;Accepts:Any Bang;[!]; 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 index 7d98cc9690e1..be4cee4726ee 100644 --- 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 @@ -19,7 +19,7 @@ RazorDocument - [0..9)::9 - [@{LF @] Transition;[@]; CSharpImplicitExpressionBody - [9..9)::0 CSharpCodeBlock - [9..9)::0 - CSharpExpressionLiteral - [9..9)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[ATD];K14 + CSharpExpressionLiteral - [9..9)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[ATD];K15 Marker;[]; CSharpStatementLiteral - [9..9)::0 - [] - Gen - SpanEditHandler;Accepts:Any Marker;[]; 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 index 178b2eab31f7..d62dfa1f5755 100644 --- 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 @@ -8,7 +8,7 @@ RazorDocument - [0..3)::3 - [@LF] Transition;[@]; CSharpImplicitExpressionBody - [1..1)::0 CSharpCodeBlock - [1..1)::0 - CSharpExpressionLiteral - [1..1)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + CSharpExpressionLiteral - [1..1)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 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.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/CSharpErrorTest/MethodProducesErrorIfWhitespaceBetweenTransitionAndBlockStartInEmbeddedExpr.stree.txt index 5dbe63612f69..dad6b39ebdbc 100644 --- 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 @@ -19,7 +19,7 @@ RazorDocument - [0..17)::17 - [@{LF @ {}LF}] Transition;[@]; CSharpImplicitExpressionBody - [9..9)::0 CSharpCodeBlock - [9..9)::0 - CSharpExpressionLiteral - [9..9)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[ATD];K14 + CSharpExpressionLiteral - [9..9)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[ATD];K15 Marker;[]; CSharpStatementLiteral - [9..16)::7 - [ {}LF] - Gen - SpanEditHandler;Accepts:Any Whitespace;[ ]; 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 index 1b3a186cb62c..2d9fcfaf18dd 100644 --- 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 @@ -8,7 +8,7 @@ RazorDocument - [0..1)::1 - [@] Transition;[@]; CSharpImplicitExpressionBody - [1..1)::0 CSharpCodeBlock - [1..1)::0 - CSharpExpressionLiteral - [1..1)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + CSharpExpressionLiteral - [1..1)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 Marker;[]; MarkupTextLiteral - [1..1)::0 - [] - Gen - SpanEditHandler;Accepts:Any Marker;[]; 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 index b5a86255d77b..f7a445e6eec6 100644 --- 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 @@ -8,7 +8,7 @@ RazorDocument - [0..2)::2 - [@/] Transition;[@]; CSharpImplicitExpressionBody - [1..1)::0 CSharpCodeBlock - [1..1)::0 - CSharpExpressionLiteral - [1..1)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + CSharpExpressionLiteral - [1..1)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 Marker;[]; MarkupTextLiteral - [1..2)::1 - [/] - Gen - SpanEditHandler;Accepts:Any ForwardSlash;[/]; 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 index f83ce55634af..cbc51176f201 100644 --- 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 @@ -8,7 +8,7 @@ RazorDocument - [0..6)::6 - [@/ foo] Transition;[@]; CSharpImplicitExpressionBody - [1..1)::0 CSharpCodeBlock - [1..1)::0 - CSharpExpressionLiteral - [1..1)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + CSharpExpressionLiteral - [1..1)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 Marker;[]; MarkupTextLiteral - [1..6)::5 - [/ foo] - Gen - SpanEditHandler;Accepts:Any ForwardSlash;[/]; 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 index 6efc85bc1834..3e0900524c3e 100644 --- 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 @@ -18,7 +18,7 @@ RazorDocument - [0..5)::5 - [@{@.}] Transition;[@]; CSharpImplicitExpressionBody - [3..3)::0 CSharpCodeBlock - [3..3)::0 - CSharpExpressionLiteral - [3..3)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[ATD];K14 + CSharpExpressionLiteral - [3..3)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[ATD];K15 Marker;[]; CSharpStatementLiteral - [3..4)::1 - [.] - Gen - SpanEditHandler;Accepts:Any Dot;[.]; 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 index a83496ddd11a..23c654a99f60 100644 --- 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 @@ -19,7 +19,7 @@ RazorDocument - [0..12)::12 - [@{LF @LF}] Transition;[@]; CSharpImplicitExpressionBody - [9..9)::0 CSharpCodeBlock - [9..9)::0 - CSharpExpressionLiteral - [9..9)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[ATD];K14 + CSharpExpressionLiteral - [9..9)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[ATD];K15 Marker;[]; CSharpStatementLiteral - [9..11)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any NewLine;[LF]; 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 index 7d2bc1804c70..90f7b384f599 100644 --- 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 @@ -18,7 +18,7 @@ RazorDocument - [0..4)::4 - [@{@}] Transition;[@]; CSharpImplicitExpressionBody - [3..3)::0 CSharpCodeBlock - [3..3)::0 - CSharpExpressionLiteral - [3..3)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[ATD];K14 + CSharpExpressionLiteral - [3..3)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[ATD];K15 Marker;[]; CSharpStatementLiteral - [3..3)::0 - [] - Gen - SpanEditHandler;Accepts:Any Marker;[]; 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 index 1b3a186cb62c..2d9fcfaf18dd 100644 --- 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 @@ -8,7 +8,7 @@ RazorDocument - [0..1)::1 - [@] Transition;[@]; CSharpImplicitExpressionBody - [1..1)::0 CSharpCodeBlock - [1..1)::0 - CSharpExpressionLiteral - [1..1)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + CSharpExpressionLiteral - [1..1)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 Marker;[]; MarkupTextLiteral - [1..1)::0 - [] - Gen - SpanEditHandler;Accepts:Any Marker;[]; 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 index 5f52cafebab2..9fa94aea12db 100644 --- 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 @@ -9,7 +9,7 @@ RazorDocument - [0..5)::5 - [foo @] Transition;[@]; CSharpImplicitExpressionBody - [5..5)::0 CSharpCodeBlock - [5..5)::0 - CSharpExpressionLiteral - [5..5)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + CSharpExpressionLiteral - [5..5)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 Marker;[]; MarkupTextLiteral - [5..5)::0 - [] - Gen - SpanEditHandler;Accepts:Any Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/WithUnexpectedTransitionsInAttributeValue_Throws.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/WithUnexpectedTransitionsInAttributeValue_Throws.stree.txt index 9c85cd9623f8..be97c431f1a8 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/WithUnexpectedTransitionsInAttributeValue_Throws.stree.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/HtmlDocumentTest/WithUnexpectedTransitionsInAttributeValue_Throws.stree.txt @@ -21,7 +21,7 @@ RazorDocument - [0..18)::18 - [] Transition;[@]; CSharpImplicitExpressionBody - [12..12)::0 CSharpCodeBlock - [12..12)::0 - CSharpExpressionLiteral - [12..12)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + CSharpExpressionLiteral - [12..12)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 Marker;[]; MarkupDynamicAttributeValue - [12..14)::2 - [ @] MarkupTextLiteral - [12..13)::1 - [ ] - Gen - SpanEditHandler;Accepts:Any @@ -33,7 +33,7 @@ RazorDocument - [0..18)::18 - [] Transition;[@]; CSharpImplicitExpressionBody - [14..14)::0 CSharpCodeBlock - [14..14)::0 - CSharpExpressionLiteral - [14..14)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K14 + CSharpExpressionLiteral - [14..14)::0 - [] - Gen - ImplicitExpressionEditHandler;Accepts:NonWhitespace;ImplicitExpression[RTD];K15 Marker;[]; MarkupTextLiteral - [14..15)::1 - ['] - Gen - SpanEditHandler;Accepts:Any SingleQuote;[']; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintErrorsWhenConstraintIdentifierIsDifferent.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintErrorsWhenConstraintIdentifierIsDifferent.cspans.txt new file mode 100644 index 000000000000..a62e3ad18de8 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintErrorsWhenConstraintIdentifierIsDifferent.cspans.txt @@ -0,0 +1,8 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [40] ) +Transition span at (2:1,0 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [25] ) +MetaCode span at (3:1,1 [6] ) (Accepts:None) - Parent: Directive block at (2:1,0 [25] ) +Code span at (9:1,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (2:1,0 [25] ) +Code span at (10:1,8 [10] ) (Accepts:NonWhitespace) - Parent: Directive block at (2:1,0 [25] ) +Code span at (20:1,18 [1] ) (Accepts:Whitespace) - Parent: Directive block at (2:1,0 [25] ) +Code span at (21:1,19 [6] ) (Accepts:Any) - Parent: Directive block at (2:1,0 [25] ) +Markup span at (27:1,25 [13] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [40] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintErrorsWhenConstraintIdentifierIsDifferent.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintErrorsWhenConstraintIdentifierIsDifferent.diag.txt new file mode 100644 index 000000000000..e3e68f61912f --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintErrorsWhenConstraintIdentifierIsDifferent.diag.txt @@ -0,0 +1 @@ +(2,26): Error RZ1039: The type parameter in the generic type constraint 'TElse' does not match the type parameter 'TSomething' defined in the directive 'custom'. diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintErrorsWhenConstraintIdentifierIsDifferent.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintErrorsWhenConstraintIdentifierIsDifferent.stree.txt new file mode 100644 index 000000000000..392682888b84 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintErrorsWhenConstraintIdentifierIsDifferent.stree.txt @@ -0,0 +1,27 @@ +RazorDocument - [0..40)::40 - [LF@custom TSomething where TElse : class] + MarkupBlock - [0..40)::40 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [2..27)::25 + RazorDirective - [2..27)::25 - Directive:{custom;SingleLine;Unrestricted} [RZ1039(27:1,25 [5] )] + CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [3..27)::24 + RazorMetaCode - [3..9)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [9..27)::18 + CSharpStatementLiteral - [9..10)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [10..20)::10 - [TSomething] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[TSomething]; + CSharpStatementLiteral - [20..21)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [21..27)::6 - [where ] - Gen - SpanEditHandler;Accepts:Any + Keyword;[where]; + Whitespace;[ ]; + MarkupTextLiteral - [27..40)::13 - [TElse : class] - Gen - SpanEditHandler;Accepts:Any + Text;[TElse]; + Whitespace;[ ]; + Text;[:]; + Whitespace;[ ]; + Text;[class]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintTokenProducesErrorWhenFirstTokenIsNotWhereKeyword.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintTokenProducesErrorWhenFirstTokenIsNotWhereKeyword.cspans.txt new file mode 100644 index 000000000000..c6f68172985d --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintTokenProducesErrorWhenFirstTokenIsNotWhereKeyword.cspans.txt @@ -0,0 +1,7 @@ +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 [19] ) +MetaCode span at (3:1,1 [6] ) (Accepts:None) - Parent: Directive block at (2:1,0 [19] ) +Code span at (9:1,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (2:1,0 [19] ) +Code span at (10:1,8 [10] ) (Accepts:NonWhitespace) - Parent: Directive block at (2:1,0 [19] ) +Code span at (20:1,18 [1] ) (Accepts:Whitespace) - Parent: Directive block at (2:1,0 [19] ) +Markup span at (21:1,19 [24] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [45] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintTokenProducesErrorWhenFirstTokenIsNotWhereKeyword.diag.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintTokenProducesErrorWhenFirstTokenIsNotWhereKeyword.diag.txt new file mode 100644 index 000000000000..cda0afecf823 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintTokenProducesErrorWhenFirstTokenIsNotWhereKeyword.diag.txt @@ -0,0 +1 @@ +(2,20): Error RZ1040: 'maybe' is not valid in this position. Valid options are 'where' diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintTokenProducesErrorWhenFirstTokenIsNotWhereKeyword.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintTokenProducesErrorWhenFirstTokenIsNotWhereKeyword.stree.txt new file mode 100644 index 000000000000..b22b0e7bb8bd --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintTokenProducesErrorWhenFirstTokenIsNotWhereKeyword.stree.txt @@ -0,0 +1,26 @@ +RazorDocument - [0..45)::45 - [LF@custom TSomething maybe TSomething : class] + MarkupBlock - [0..45)::45 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [2..21)::19 + RazorDirective - [2..21)::19 - Directive:{custom;SingleLine;Unrestricted} [RZ1040(21:1,19 [5] )] + CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [3..21)::18 + RazorMetaCode - [3..9)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [9..21)::12 + CSharpStatementLiteral - [9..10)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [10..20)::10 - [TSomething] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[TSomething]; + CSharpStatementLiteral - [20..21)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + MarkupTextLiteral - [21..45)::24 - [maybe TSomething : class] - Gen - SpanEditHandler;Accepts:Any + Text;[maybe]; + Whitespace;[ ]; + Text;[TSomething]; + Whitespace;[ ]; + Text;[:]; + Whitespace;[ ]; + Text;[class]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintTokenWorksWhenAtEndOfFile.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintTokenWorksWhenAtEndOfFile.cspans.txt new file mode 100644 index 000000000000..7028f82b1f32 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintTokenWorksWhenAtEndOfFile.cspans.txt @@ -0,0 +1,8 @@ +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 [10] ) (Accepts:NonWhitespace) - Parent: Directive block at (2:1,0 [43] ) +Code span at (20:1,18 [1] ) (Accepts:Whitespace) - Parent: Directive block at (2:1,0 [43] ) +Code span at (21:1,19 [24] ) (Accepts:NonWhitespace) - Parent: Directive block at (2:1,0 [43] ) +Markup span at (45:1,43 [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_GenericConstraintTokenWorksWhenAtEndOfFile.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintTokenWorksWhenAtEndOfFile.stree.txt new file mode 100644 index 000000000000..21bf4bab3c62 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_GenericConstraintTokenWorksWhenAtEndOfFile.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..45)::45 - [LF@custom TSomething where TSomething : class] + 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..20)::10 - [TSomething] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[TSomething]; + CSharpStatementLiteral - [20..21)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [21..45)::24 - [where TSomething : class] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Keyword;[where]; + Whitespace;[ ]; + Identifier;[TSomething]; + Whitespace;[ ]; + Colon;[:]; + Whitespace;[ ]; + Keyword;[class]; + MarkupTextLiteral - [45..45)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsGenericConstraintsToken.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsGenericConstraintsToken.cspans.txt new file mode 100644 index 000000000000..8373166431f7 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsGenericConstraintsToken.cspans.txt @@ -0,0 +1,9 @@ +Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [47] ) +Transition span at (2:1,0 [1] ) (Accepts:None) - Parent: Directive block at (2:1,0 [45] ) +MetaCode span at (3:1,1 [6] ) (Accepts:None) - Parent: Directive block at (2:1,0 [45] ) +Code span at (9:1,7 [1] ) (Accepts:Whitespace) - Parent: Directive block at (2:1,0 [45] ) +Code span at (10:1,8 [10] ) (Accepts:NonWhitespace) - Parent: Directive block at (2:1,0 [45] ) +Code span at (20:1,18 [1] ) (Accepts:Whitespace) - Parent: Directive block at (2:1,0 [45] ) +Code span at (21:1,19 [24] ) (Accepts:NonWhitespace) - Parent: Directive block at (2:1,0 [45] ) +Markup span at (45:1,43 [2] ) (Accepts:Whitespace) - Parent: Directive block at (2:1,0 [45] ) +Markup span at (47:2,0 [0] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [47] ) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsGenericConstraintsToken.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsGenericConstraintsToken.stree.txt new file mode 100644 index 000000000000..05706a1cbef0 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_UnderstandsGenericConstraintsToken.stree.txt @@ -0,0 +1,30 @@ +RazorDocument - [0..47)::47 - [LF@custom TSomething where TSomething : classLF] + MarkupBlock - [0..47)::47 + MarkupTextLiteral - [0..2)::2 - [LF] - Gen - SpanEditHandler;Accepts:Any + NewLine;[LF]; + CSharpCodeBlock - [2..47)::45 + RazorDirective - [2..47)::45 - Directive:{custom;SingleLine;Unrestricted} + CSharpTransition - [2..3)::1 - Gen - SpanEditHandler;Accepts:None + Transition;[@]; + RazorDirectiveBody - [3..47)::44 + RazorMetaCode - [3..9)::6 - Gen - SpanEditHandler;Accepts:None + Identifier;[custom]; + CSharpCodeBlock - [9..47)::38 + CSharpStatementLiteral - [9..10)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [10..20)::10 - [TSomething] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[TSomething]; + CSharpStatementLiteral - [20..21)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [21..45)::24 - [where TSomething : class] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Keyword;[where]; + Whitespace;[ ]; + Identifier;[TSomething]; + Whitespace;[ ]; + Colon;[:]; + Whitespace;[ ]; + Keyword;[class]; + MarkupEphemeralTextLiteral - [45..47)::2 - [LF] - Gen - SpanEditHandler;Accepts:Whitespace + NewLine;[LF]; + MarkupTextLiteral - [47..47)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_WorksWhenAtEndOfFile.cspans.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_WorksWhenAtEndOfFile.cspans.txt new file mode 100644 index 000000000000..7028f82b1f32 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_WorksWhenAtEndOfFile.cspans.txt @@ -0,0 +1,8 @@ +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 [10] ) (Accepts:NonWhitespace) - Parent: Directive block at (2:1,0 [43] ) +Code span at (20:1,18 [1] ) (Accepts:Whitespace) - Parent: Directive block at (2:1,0 [43] ) +Code span at (21:1,19 [24] ) (Accepts:NonWhitespace) - Parent: Directive block at (2:1,0 [43] ) +Markup span at (45:1,43 [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_WorksWhenAtEndOfFile.stree.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_WorksWhenAtEndOfFile.stree.txt new file mode 100644 index 000000000000..21bf4bab3c62 --- /dev/null +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/ParserTests/RazorDirectivesTest/DirectiveDescriptor_WorksWhenAtEndOfFile.stree.txt @@ -0,0 +1,28 @@ +RazorDocument - [0..45)::45 - [LF@custom TSomething where TSomething : class] + 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..20)::10 - [TSomething] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Identifier;[TSomething]; + CSharpStatementLiteral - [20..21)::1 - [ ] - Gen - SpanEditHandler;Accepts:Whitespace + Whitespace;[ ]; + CSharpStatementLiteral - [21..45)::24 - [where TSomething : class] - Gen - DirectiveTokenEditHandler;Accepts:NonWhitespace + Keyword;[where]; + Whitespace;[ ]; + Identifier;[TSomething]; + Whitespace;[ ]; + Colon;[:]; + Whitespace;[ ]; + Keyword;[class]; + MarkupTextLiteral - [45..45)::0 - [] - Gen - SpanEditHandler;Accepts:Any + Marker;[]; 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 index 8ce5207ab419..545aa38c38e3 100644 --- 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 @@ -20,7 +20,7 @@ RazorDocument - [0..30)::30 - [
    ] 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 + CSharpExpressionLiteral - [18..23)::5 - [items] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K15 Text;[items]; MarkupTextLiteral - [23..24)::1 - ['] - Gen - SpanEditHandler;Accepts:Any SingleQuote;[']; 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 index 84a9a3756385..94bcb5a0c411 100644 --- 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 @@ -20,7 +20,7 @@ RazorDocument - [0..32)::32 - [
      ] 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 + CSharpExpressionLiteral - [20..25)::5 - [items] - Gen - ImplicitExpressionEditHandler;Accepts:AnyExceptNewline;ImplicitExpression[ATD];K15 Text;[items]; MarkupTextLiteral - [25..26)::1 - ['] - Gen - SpanEditHandler;Accepts:Any SingleQuote;[']; 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 index 0acd0c5753a1..aebea3355912 100644 --- 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 @@ -18,7 +18,7 @@ RazorDocument - [0..55)::55 - [