Enables the correct processing of data- attributes for components.
\n\nCommit migrated from 7ae8a8c842
This commit is contained in:
parent
43824a4c12
commit
9deb4401e4
|
|
@ -473,7 +473,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
|
||||
var name = node.Name.GetContent();
|
||||
if (name.StartsWith("data-", StringComparison.OrdinalIgnoreCase) &&
|
||||
!_featureFlags.EXPERIMENTAL_AllowConditionalDataDashAttributes)
|
||||
!_featureFlags.AllowConditionalDataDashAttributes)
|
||||
{
|
||||
Visit(prefix);
|
||||
Visit(node.Value);
|
||||
|
|
@ -518,7 +518,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
{
|
||||
var name = node.Name.GetContent();
|
||||
if (name.StartsWith("data-", StringComparison.OrdinalIgnoreCase) &&
|
||||
!_featureFlags.EXPERIMENTAL_AllowConditionalDataDashAttributes)
|
||||
!_featureFlags.AllowConditionalDataDashAttributes)
|
||||
{
|
||||
base.VisitMarkupMinimizedAttributeBlock(node);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
DesignTime = designTime;
|
||||
ParseLeadingDirectives = parseLeadingDirectives;
|
||||
Version = version;
|
||||
FeatureFlags = RazorParserFeatureFlags.Create(Version);
|
||||
FeatureFlags = RazorParserFeatureFlags.Create(Version, fileKind);
|
||||
FileKind = fileKind;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
|
||||
public override RazorParserOptions Build()
|
||||
{
|
||||
return new DefaultRazorParserOptions(Directives.ToArray(), DesignTime, ParseLeadingDirectives, LanguageVersion, FileKind);
|
||||
return new DefaultRazorParserOptions(Directives.ToArray(), DesignTime, ParseLeadingDirectives, LanguageVersion, FileKind ?? FileKinds.Legacy);
|
||||
}
|
||||
|
||||
public override void SetDesignTime(bool designTime)
|
||||
|
|
|
|||
|
|
@ -1923,10 +1923,17 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
|
||||
private bool IsConditionalAttributeName(string name)
|
||||
{
|
||||
var attributeCanBeConditional =
|
||||
Context.FeatureFlags.EXPERIMENTAL_AllowConditionalDataDashAttributes ||
|
||||
!name.StartsWith("data-", StringComparison.OrdinalIgnoreCase);
|
||||
return attributeCanBeConditional;
|
||||
if (Context.FeatureFlags.AllowConditionalDataDashAttributes)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!name.StartsWith("data-", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void NestingBlock(in SyntaxListBuilder<RazorSyntaxNode> builder, Tuple<string, string> nestingSequences)
|
||||
|
|
|
|||
|
|
@ -1,18 +1,25 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Language
|
||||
{
|
||||
internal abstract class RazorParserFeatureFlags
|
||||
{
|
||||
public static RazorParserFeatureFlags Create(RazorLanguageVersion version)
|
||||
public static RazorParserFeatureFlags Create(RazorLanguageVersion version, string fileKind)
|
||||
{
|
||||
if (fileKind == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(fileKind));
|
||||
}
|
||||
|
||||
var allowMinimizedBooleanTagHelperAttributes = false;
|
||||
var allowHtmlCommentsInTagHelpers = false;
|
||||
var allowComponentFileKind = false;
|
||||
var allowRazorInAllCodeBlocks = false;
|
||||
var allowUsingVariableDeclarations = false;
|
||||
var experimental_AllowConditionalDataDashAttributes = false;
|
||||
var allowConditionalDataDashAttributes = false;
|
||||
|
||||
if (version.CompareTo(RazorLanguageVersion.Version_2_1) >= 0)
|
||||
{
|
||||
|
|
@ -29,9 +36,14 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
allowUsingVariableDeclarations = true;
|
||||
}
|
||||
|
||||
if (FileKinds.IsComponent(fileKind))
|
||||
{
|
||||
allowConditionalDataDashAttributes = true;
|
||||
}
|
||||
|
||||
if (version.CompareTo(RazorLanguageVersion.Experimental) >= 0)
|
||||
{
|
||||
experimental_AllowConditionalDataDashAttributes = true;
|
||||
allowConditionalDataDashAttributes = true;
|
||||
}
|
||||
|
||||
return new DefaultRazorParserFeatureFlags(
|
||||
|
|
@ -40,7 +52,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
allowComponentFileKind,
|
||||
allowRazorInAllCodeBlocks,
|
||||
allowUsingVariableDeclarations,
|
||||
experimental_AllowConditionalDataDashAttributes);
|
||||
allowConditionalDataDashAttributes);
|
||||
}
|
||||
|
||||
public abstract bool AllowMinimizedBooleanTagHelperAttributes { get; }
|
||||
|
|
@ -53,7 +65,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
|
||||
public abstract bool AllowUsingVariableDeclarations { get; }
|
||||
|
||||
public abstract bool EXPERIMENTAL_AllowConditionalDataDashAttributes { get; }
|
||||
public abstract bool AllowConditionalDataDashAttributes { get; }
|
||||
|
||||
private class DefaultRazorParserFeatureFlags : RazorParserFeatureFlags
|
||||
{
|
||||
|
|
@ -63,14 +75,14 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
bool allowComponentFileKind,
|
||||
bool allowRazorInAllCodeBlocks,
|
||||
bool allowUsingVariableDeclarations,
|
||||
bool experimental_AllowConditionalDataDashAttributes)
|
||||
bool allowConditionalDataDashAttributesInComponents)
|
||||
{
|
||||
AllowMinimizedBooleanTagHelperAttributes = allowMinimizedBooleanTagHelperAttributes;
|
||||
AllowHtmlCommentsInTagHelpers = allowHtmlCommentsInTagHelpers;
|
||||
AllowComponentFileKind = allowComponentFileKind;
|
||||
AllowRazorInAllCodeBlocks = allowRazorInAllCodeBlocks;
|
||||
AllowUsingVariableDeclarations = allowUsingVariableDeclarations;
|
||||
EXPERIMENTAL_AllowConditionalDataDashAttributes = experimental_AllowConditionalDataDashAttributes;
|
||||
AllowConditionalDataDashAttributes = allowConditionalDataDashAttributesInComponents;
|
||||
}
|
||||
|
||||
public override bool AllowMinimizedBooleanTagHelperAttributes { get; }
|
||||
|
|
@ -83,7 +95,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
|
||||
public override bool AllowUsingVariableDeclarations { get; }
|
||||
|
||||
public override bool EXPERIMENTAL_AllowConditionalDataDashAttributes { get; }
|
||||
public override bool AllowConditionalDataDashAttributes { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
designTime: false,
|
||||
parseLeadingDirectives: false,
|
||||
version: RazorLanguageVersion.Latest,
|
||||
fileKind: null);
|
||||
fileKind: FileKinds.Legacy);
|
||||
}
|
||||
|
||||
public static RazorParserOptions Create(Action<RazorParserOptionsBuilder> configure)
|
||||
{
|
||||
return Create(configure, fileKind: null);
|
||||
return Create(configure, fileKind: FileKinds.Legacy);
|
||||
}
|
||||
|
||||
public static RazorParserOptions Create(Action<RazorParserOptionsBuilder> configure, string fileKind)
|
||||
|
|
@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
throw new ArgumentNullException(nameof(configure));
|
||||
}
|
||||
|
||||
var builder = new DefaultRazorParserOptionsBuilder(designTime: false, version: RazorLanguageVersion.Latest, fileKind);
|
||||
var builder = new DefaultRazorParserOptionsBuilder(designTime: false, version: RazorLanguageVersion.Latest, fileKind ?? FileKinds.Legacy);
|
||||
configure(builder);
|
||||
var options = builder.Build();
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
throw new ArgumentNullException(nameof(configure));
|
||||
}
|
||||
|
||||
var builder = new DefaultRazorParserOptionsBuilder(designTime: true, version: RazorLanguageVersion.Latest, fileKind);
|
||||
var builder = new DefaultRazorParserOptionsBuilder(designTime: true, version: RazorLanguageVersion.Latest, fileKind ?? FileKinds.Legacy);
|
||||
configure(builder);
|
||||
var options = builder.Build();
|
||||
|
||||
|
|
|
|||
|
|
@ -2852,6 +2852,27 @@ namespace Test.Shared
|
|||
CompileToAssembly(generated);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Element_WithRef_AndOtherAttributes()
|
||||
{
|
||||
// Arrange/Act
|
||||
var generated = CompileToCSharp(@"
|
||||
<input type=""text"" data-slider-min=""@Min"" ref=""@_element"" />
|
||||
|
||||
@functions {
|
||||
private ElementRef _element;
|
||||
|
||||
[Parameter] protected int Min { get; set; }
|
||||
public void Foo() { System.GC.KeepAlive(_element); }
|
||||
}
|
||||
");
|
||||
|
||||
// Assert
|
||||
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
|
||||
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
|
||||
CompileToAssembly(generated);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Component_WithRef()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2161,14 +2161,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
bool allowComponentFileKind = false,
|
||||
bool allowRazorInCodeBlockDirectives = false,
|
||||
bool allowUsingVariableDeclarations = false,
|
||||
bool experimental_AllowConditionalDataDashAttributes = false)
|
||||
bool allowConditionalDataDashAttributesInComponents = false)
|
||||
{
|
||||
AllowMinimizedBooleanTagHelperAttributes = allowMinimizedBooleanTagHelperAttributes;
|
||||
AllowHtmlCommentsInTagHelpers = allowHtmlCommentsInTagHelper;
|
||||
AllowComponentFileKind = allowComponentFileKind;
|
||||
AllowRazorInAllCodeBlocks = allowRazorInCodeBlockDirectives;
|
||||
AllowUsingVariableDeclarations = allowUsingVariableDeclarations;
|
||||
EXPERIMENTAL_AllowConditionalDataDashAttributes = experimental_AllowConditionalDataDashAttributes;
|
||||
AllowConditionalDataDashAttributes = allowConditionalDataDashAttributesInComponents;
|
||||
}
|
||||
|
||||
public override bool AllowMinimizedBooleanTagHelperAttributes { get; }
|
||||
|
|
@ -2181,7 +2181,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
|
||||
public override bool AllowUsingVariableDeclarations { get; }
|
||||
|
||||
public override bool EXPERIMENTAL_AllowConditionalDataDashAttributes { get; }
|
||||
public override bool AllowConditionalDataDashAttributes { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -734,7 +734,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
EvaluateData(
|
||||
descriptors,
|
||||
document,
|
||||
featureFlags: RazorParserFeatureFlags.Create(RazorLanguageVersion.Version_2_0));
|
||||
featureFlags: RazorParserFeatureFlags.Create(RazorLanguageVersion.Version_2_0, FileKinds.Legacy));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
public void Create_LatestVersion_AllowsMinimizedBooleanTagHelperAttributes()
|
||||
{
|
||||
// Arrange & Act
|
||||
var context = RazorParserFeatureFlags.Create(RazorLanguageVersion.Version_2_1);
|
||||
var context = RazorParserFeatureFlags.Create(RazorLanguageVersion.Version_2_1, FileKinds.Legacy);
|
||||
|
||||
// Assert
|
||||
Assert.True(context.AllowMinimizedBooleanTagHelperAttributes);
|
||||
|
|
@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
public void Create_OlderVersion_DoesNotAllowMinimizedBooleanTagHelperAttributes()
|
||||
{
|
||||
// Arrange & Act
|
||||
var context = RazorParserFeatureFlags.Create(RazorLanguageVersion.Version_1_1);
|
||||
var context = RazorParserFeatureFlags.Create(RazorLanguageVersion.Version_1_1, FileKinds.Legacy);
|
||||
|
||||
// Assert
|
||||
Assert.False(context.AllowMinimizedBooleanTagHelperAttributes);
|
||||
|
|
|
|||
|
|
@ -18,8 +18,10 @@ Document -
|
|||
IntermediateToken - (2:0,2 [40] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n var myValue = "Expression value";\n
|
||||
MarkupElement - (45:3,0 [55] x:\dir\subdir\Test\TestComponent.cshtml) - elem
|
||||
HtmlAttribute - (50:3,5 [25] x:\dir\subdir\Test\TestComponent.cshtml) - data-abc=" - "
|
||||
HtmlAttributeValue - (61:3,16 [13] x:\dir\subdir\Test\TestComponent.cshtml) -
|
||||
IntermediateToken - (61:3,16 [13] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Literal value
|
||||
HtmlAttributeValue - (61:3,16 [7] x:\dir\subdir\Test\TestComponent.cshtml) -
|
||||
IntermediateToken - (61:3,16 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Literal
|
||||
HtmlAttributeValue - (68:3,23 [6] x:\dir\subdir\Test\TestComponent.cshtml) -
|
||||
IntermediateToken - (69:3,24 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - value
|
||||
HtmlAttribute - (75:3,30 [22] x:\dir\subdir\Test\TestComponent.cshtml) - data-def=" - "
|
||||
CSharpExpressionAttributeValue - (86:3,41 [10] x:\dir\subdir\Test\TestComponent.cshtml) -
|
||||
IntermediateToken - (88:3,43 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - myValue
|
||||
|
|
|
|||
|
|
@ -18,8 +18,10 @@ Document -
|
|||
IntermediateToken - (2:0,2 [40] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n var myValue = "Expression value";\n
|
||||
MarkupElement - (45:3,0 [53] x:\dir\subdir\Test\TestComponent.cshtml) - elem
|
||||
HtmlAttribute - (50:3,5 [25] x:\dir\subdir\Test\TestComponent.cshtml) - data-abc=" - "
|
||||
HtmlAttributeValue - (61:3,16 [13] x:\dir\subdir\Test\TestComponent.cshtml) -
|
||||
IntermediateToken - (61:3,16 [13] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Literal value
|
||||
HtmlAttributeValue - (61:3,16 [7] x:\dir\subdir\Test\TestComponent.cshtml) -
|
||||
IntermediateToken - (61:3,16 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Literal
|
||||
HtmlAttributeValue - (68:3,23 [6] x:\dir\subdir\Test\TestComponent.cshtml) -
|
||||
IntermediateToken - (69:3,24 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - value
|
||||
HtmlAttribute - (75:3,30 [20] x:\dir\subdir\Test\TestComponent.cshtml) - data-def=" - "
|
||||
CSharpExpressionAttributeValue - (86:3,41 [8] x:\dir\subdir\Test\TestComponent.cshtml) -
|
||||
IntermediateToken - (87:3,42 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - myValue
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
// <auto-generated/>
|
||||
#pragma warning disable 1591
|
||||
namespace Test
|
||||
{
|
||||
#line hidden
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
|
||||
{
|
||||
#pragma warning disable 219
|
||||
private void __RazorDirectiveTokenHelpers__() {
|
||||
}
|
||||
#pragma warning restore 219
|
||||
#pragma warning disable 0414
|
||||
private static System.Object __o = null;
|
||||
#pragma warning restore 0414
|
||||
#pragma warning disable 1998
|
||||
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder)
|
||||
{
|
||||
__o =
|
||||
#nullable restore
|
||||
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
|
||||
Min
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#nullable disable
|
||||
;
|
||||
#nullable restore
|
||||
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
|
||||
_element = default(Microsoft.AspNetCore.Components.ElementRef);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#nullable disable
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
#nullable restore
|
||||
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
|
||||
|
||||
private ElementRef _element;
|
||||
|
||||
[Parameter] protected int Min { get; set; }
|
||||
public void Foo() { System.GC.KeepAlive(_element); }
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#nullable disable
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
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 - (104:5,1 [37] ) - Microsoft.AspNetCore.Components
|
||||
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
|
||||
DesignTimeDirective -
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - #pragma warning disable 0414
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - private static System.Object __o = null;
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - #pragma warning restore 0414
|
||||
MethodDeclaration - - protected override - void - BuildRenderTree
|
||||
MarkupElement - (0:0,0 [60] x:\dir\subdir\Test\TestComponent.cshtml) - input
|
||||
HtmlAttribute - - type=" - "
|
||||
HtmlAttributeValue - (13:0,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) -
|
||||
IntermediateToken - (13:0,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - text
|
||||
HtmlAttribute - - data-slider-min=" - "
|
||||
CSharpExpressionAttributeValue - (36:0,36 [4] x:\dir\subdir\Test\TestComponent.cshtml) -
|
||||
IntermediateToken - (37:0,37 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Min
|
||||
ReferenceCapture - (48:0,48 [8] x:\dir\subdir\Test\TestComponent.cshtml) - _element
|
||||
HtmlContent - (60:0,60 [4] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
IntermediateToken - (60:0,60 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
|
||||
HtmlContent - (238:7,5 [2] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
IntermediateToken - (238:7,5 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
|
||||
CSharpCode - (76:2,12 [161] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
IntermediateToken - (76:2,12 [161] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private ElementRef _element;\n\n [Parameter] protected int Min { get; set; }\n public void Foo() { System.GC.KeepAlive(_element); }\n
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
Source Location: (37:0,37 [3] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
|Min|
|
||||
Generated Location: (900:25,37 [3] )
|
||||
|Min|
|
||||
|
||||
Source Location: (48:0,48 [8] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
|_element|
|
||||
Generated Location: (1088:33,48 [8] )
|
||||
|_element|
|
||||
|
||||
Source Location: (76:2,12 [161] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
|
|
||||
private ElementRef _element;
|
||||
|
||||
[Parameter] protected int Min { get; set; }
|
||||
public void Foo() { System.GC.KeepAlive(_element); }
|
||||
|
|
||||
Generated Location: (1334:42,12 [161] )
|
||||
|
|
||||
private ElementRef _element;
|
||||
|
||||
[Parameter] protected int Min { get; set; }
|
||||
public void Foo() { System.GC.KeepAlive(_element); }
|
||||
|
|
||||
|
||||
|
|
@ -11,8 +11,10 @@ Document -
|
|||
IntermediateToken - (2:0,2 [40] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n var myValue = "Expression value";\n
|
||||
MarkupElement - (45:3,0 [55] x:\dir\subdir\Test\TestComponent.cshtml) - elem
|
||||
HtmlAttribute - (50:3,5 [25] x:\dir\subdir\Test\TestComponent.cshtml) - data-abc=" - "
|
||||
HtmlAttributeValue - (61:3,16 [13] x:\dir\subdir\Test\TestComponent.cshtml) -
|
||||
IntermediateToken - (61:3,16 [13] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Literal value
|
||||
HtmlAttributeValue - (61:3,16 [7] x:\dir\subdir\Test\TestComponent.cshtml) -
|
||||
IntermediateToken - (61:3,16 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Literal
|
||||
HtmlAttributeValue - (68:3,23 [6] x:\dir\subdir\Test\TestComponent.cshtml) -
|
||||
IntermediateToken - (69:3,24 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - value
|
||||
HtmlAttribute - (75:3,30 [22] x:\dir\subdir\Test\TestComponent.cshtml) - data-def=" - "
|
||||
CSharpExpressionAttributeValue - (86:3,41 [10] x:\dir\subdir\Test\TestComponent.cshtml) -
|
||||
IntermediateToken - (88:3,43 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - myValue
|
||||
|
|
|
|||
|
|
@ -11,8 +11,10 @@ Document -
|
|||
IntermediateToken - (2:0,2 [40] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n var myValue = "Expression value";\n
|
||||
MarkupElement - (45:3,0 [53] x:\dir\subdir\Test\TestComponent.cshtml) - elem
|
||||
HtmlAttribute - (50:3,5 [25] x:\dir\subdir\Test\TestComponent.cshtml) - data-abc=" - "
|
||||
HtmlAttributeValue - (61:3,16 [13] x:\dir\subdir\Test\TestComponent.cshtml) -
|
||||
IntermediateToken - (61:3,16 [13] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Literal value
|
||||
HtmlAttributeValue - (61:3,16 [7] x:\dir\subdir\Test\TestComponent.cshtml) -
|
||||
IntermediateToken - (61:3,16 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Literal
|
||||
HtmlAttributeValue - (68:3,23 [6] x:\dir\subdir\Test\TestComponent.cshtml) -
|
||||
IntermediateToken - (69:3,24 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - value
|
||||
HtmlAttribute - (75:3,30 [20] x:\dir\subdir\Test\TestComponent.cshtml) - data-def=" - "
|
||||
CSharpExpressionAttributeValue - (86:3,41 [8] x:\dir\subdir\Test\TestComponent.cshtml) -
|
||||
IntermediateToken - (87:3,42 [7] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - myValue
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
// <auto-generated/>
|
||||
#pragma warning disable 1591
|
||||
namespace Test
|
||||
{
|
||||
#line hidden
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
|
||||
{
|
||||
#pragma warning disable 1998
|
||||
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder)
|
||||
{
|
||||
builder.OpenElement(0, "input");
|
||||
builder.AddAttribute(1, "type", "text");
|
||||
builder.AddAttribute(2, "data-slider-min",
|
||||
#nullable restore
|
||||
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
|
||||
Min
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#nullable disable
|
||||
);
|
||||
builder.AddElementReferenceCapture(3, (__value) => {
|
||||
#nullable restore
|
||||
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
|
||||
_element = __value;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#nullable disable
|
||||
}
|
||||
);
|
||||
builder.CloseElement();
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
#nullable restore
|
||||
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
|
||||
|
||||
private ElementRef _element;
|
||||
|
||||
[Parameter] protected int Min { get; set; }
|
||||
public void Foo() { System.GC.KeepAlive(_element); }
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#nullable disable
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
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 - (104:5,1 [39] ) - Microsoft.AspNetCore.Components
|
||||
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
|
||||
MethodDeclaration - - protected override - void - BuildRenderTree
|
||||
MarkupElement - (0:0,0 [60] x:\dir\subdir\Test\TestComponent.cshtml) - input
|
||||
HtmlAttribute - - type=" - "
|
||||
HtmlAttributeValue - (13:0,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) -
|
||||
IntermediateToken - (13:0,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - text
|
||||
HtmlAttribute - - data-slider-min=" - "
|
||||
CSharpExpressionAttributeValue - (36:0,36 [4] x:\dir\subdir\Test\TestComponent.cshtml) -
|
||||
IntermediateToken - (37:0,37 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Min
|
||||
ReferenceCapture - (48:0,48 [8] x:\dir\subdir\Test\TestComponent.cshtml) - _element
|
||||
CSharpCode - (76:2,12 [161] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
IntermediateToken - (76:2,12 [161] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private ElementRef _element;\n\n [Parameter] protected int Min { get; set; }\n public void Foo() { System.GC.KeepAlive(_element); }\n
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
Source Location: (48:0,48 [8] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
|_element|
|
||||
Generated Location: (1024:29,48 [8] )
|
||||
|_element|
|
||||
|
||||
Source Location: (76:2,12 [161] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
|
|
||||
private ElementRef _element;
|
||||
|
||||
[Parameter] protected int Min { get; set; }
|
||||
public void Foo() { System.GC.KeepAlive(_element); }
|
||||
|
|
||||
Generated Location: (1294:41,12 [161] )
|
||||
|
|
||||
private ElementRef _element;
|
||||
|
||||
[Parameter] protected int Min { get; set; }
|
||||
public void Foo() { System.GC.KeepAlive(_element); }
|
||||
|
|
||||
|
||||
|
|
@ -254,12 +254,13 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
designTime,
|
||||
parseLeadingDirectives: false,
|
||||
version: version,
|
||||
fileKind: FileKinds.Legacy,
|
||||
featureFlags: featureFlags);
|
||||
}
|
||||
|
||||
private class TestRazorParserOptions : RazorParserOptions
|
||||
{
|
||||
public TestRazorParserOptions(DirectiveDescriptor[] directives, bool designTime, bool parseLeadingDirectives, RazorLanguageVersion version, RazorParserFeatureFlags featureFlags = null)
|
||||
public TestRazorParserOptions(DirectiveDescriptor[] directives, bool designTime, bool parseLeadingDirectives, RazorLanguageVersion version, string fileKind, RazorParserFeatureFlags featureFlags = null)
|
||||
{
|
||||
if (directives == null)
|
||||
{
|
||||
|
|
@ -270,11 +271,14 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
|
|||
DesignTime = designTime;
|
||||
ParseLeadingDirectives = parseLeadingDirectives;
|
||||
Version = version;
|
||||
FeatureFlags = featureFlags ?? RazorParserFeatureFlags.Create(Version);
|
||||
FileKind = fileKind;
|
||||
FeatureFlags = featureFlags ?? RazorParserFeatureFlags.Create(Version, fileKind);
|
||||
}
|
||||
|
||||
public override bool DesignTime { get; }
|
||||
|
||||
internal override string FileKind { get; }
|
||||
|
||||
public override IReadOnlyCollection<DirectiveDescriptor> Directives { get; }
|
||||
|
||||
public override bool ParseLeadingDirectives { get; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue