This change makes @ref define a field for you by default. We didn't do
this originally because we weren't sure if the compiler generating a
field would always be what you want, and more importantly,
we didn't have the expressiveness to add an opt-out.

Now that we have directive attributes, it's easy to create an opt-out
for the field generation. The special thing about it is that where
you opt-out has to be static. For this reason the @bind:suppressField
attribute cannot be used with a value, you either have the flag or not.

Additionally, we don't support automatic field generation for
generics, because usually we can't write the field name. If we
want to in the future could make this work when the generic
type arguments are specified. So in the case of generics,
you have to opt-out, and you will get a diagnostic
that tells you so.\n\nCommit migrated from dadf9faf22
This commit is contained in:
Ryan Nowak 2019-07-01 13:58:25 -07:00 committed by GitHub
parent 0659180119
commit 895ad896c7
76 changed files with 1076 additions and 302 deletions

View File

@ -263,8 +263,13 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
string.Format(CultureInfo.InvariantCulture, InstanceMethodFormat, instanceName, methodName));
}
public static CodeWriter WriteField(this CodeWriter writer, IList<string> modifiers, string typeName, string fieldName)
public static CodeWriter WriteField(this CodeWriter writer, IList<string> suppressWarnings, IList<string> modifiers, string typeName, string fieldName)
{
if (suppressWarnings == null)
{
throw new ArgumentNullException(nameof(suppressWarnings));
}
if (modifiers == null)
{
throw new ArgumentNullException(nameof(modifiers));
@ -280,6 +285,12 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
throw new ArgumentNullException(nameof(fieldName));
}
for (var i = 0; i < suppressWarnings.Count; i++)
{
writer.Write("#pragma warning disable ");
writer.WriteLine(suppressWarnings[i]);
}
for (var i = 0; i < modifiers.Count; i++)
{
writer.Write(modifiers[i]);
@ -292,6 +303,12 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
writer.Write(";");
writer.WriteLine();
for (var i = suppressWarnings.Count - 1; i >= 0; i--)
{
writer.Write("#pragma warning restore ");
writer.WriteLine(suppressWarnings[i]);
}
return writer;
}

View File

@ -206,7 +206,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
public override void VisitFieldDeclaration(FieldDeclarationIntermediateNode node)
{
Context.CodeWriter.WriteField(node.Modifiers, node.FieldType, node.FieldName);
Context.CodeWriter.WriteField(node.SuppressWarnings, node.Modifiers, node.FieldType, node.FieldName);
}
public override void VisitPropertyDeclaration(PropertyDeclarationIntermediateNode node)

View File

@ -193,7 +193,10 @@
<value>route template</value>
</data>
<data name="RefTagHelper_Documentation" xml:space="preserve">
<value>Populates the specified field or property with a reference to the element or component.</value>
<value>Generates the specified field, and populates it during rendering with a reference to the element or component.</value>
</data>
<data name="RefTagHelper_SuppressField_Documentation" xml:space="preserve">
<value>Suppresses the generation of a field by '@ref'. Specify '@ref:suppressField' to define your own property or field.</value>
</data>
<data name="SplatTagHelper_Documentation" xml:space="preserve">
<value>Merges a collection of attributes into the current element or component.</value>

View File

@ -423,5 +423,31 @@ namespace Microsoft.AspNetCore.Razor.Language.Components
{
return RazorDiagnostic.Create(DuplicateComponentParameterDirective, source ?? SourceSpan.Undefined, attributeName, directiveAttributeName);
}
public static readonly RazorDiagnosticDescriptor RefSuppressFieldNotMinimized =
new RazorDiagnosticDescriptor(
$"{DiagnosticPrefix}10011",
() =>
"The directive attribute '@ref:suppressField' must be used as a minimized attribute. Providing an attribute value like '@ref:suppressField=\"false\"' " +
"is not supported.",
RazorDiagnosticSeverity.Error);
public static RazorDiagnostic Create_RefSuppressFieldNotMinimized(SourceSpan? source = null)
{
return RazorDiagnostic.Create(RefSuppressFieldNotMinimized, source ?? SourceSpan.Undefined);
}
public static readonly RazorDiagnosticDescriptor RefSuppressFieldRequiredForGeneric =
new RazorDiagnosticDescriptor(
$"{DiagnosticPrefix}10012",
() =>
"Using '@ref' on a generic-typed component requires manually defining a field to hold the component reference. Use '@ref:suppressField' to " +
"suppress field generation, and manually define a field inside '@code {{ }}' to contain the reference.",
RazorDiagnosticSeverity.Error);
public static RazorDiagnostic Create_RefSuppressFieldRequiredForGeneric(SourceSpan? source = null)
{
return RazorDiagnostic.Create(RefSuppressFieldRequiredForGeneric, source ?? SourceSpan.Undefined);
}
}
}

View File

@ -1,6 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Linq;
using Microsoft.AspNetCore.Razor.Language.Intermediate;
namespace Microsoft.AspNetCore.Razor.Language.Components
@ -33,34 +35,109 @@ namespace Microsoft.AspNetCore.Razor.Language.Components
if (node.TagHelper.IsRefTagHelper())
{
reference.Replace(RewriteUsage(@class, reference.Parent, node));
// We've found an @ref directive attribute.
//
// If we can't get a nonempty identifier, do nothing because there will
// already be a diagnostic for empty values
var identifier = DetermineIdentifierToken(node);
if (identifier == null)
{
continue;
}
var rewritten = RewriteUsage(reference.Parent, identifier);
reference.Replace(rewritten);
// Now we need to check if the field generation has been suppressed.
//
// You have to suppress field generation for generic types because we don't know the
// type name to create the field.
var generateField = ShouldGenerateField(reference.Parent);
// Insert the field with other fields, near the top of the class.
if (generateField)
{
var position = 0;
while (position < @class.Children.Count && @class.Children[i] is FieldDeclarationIntermediateNode)
{
position++;
}
@class.Children.Insert(position, CreateField(rewritten.FieldTypeName, identifier));
}
}
}
}
private IntermediateNode RewriteUsage(ClassDeclarationIntermediateNode classNode, IntermediateNode parent, TagHelperDirectiveAttributeIntermediateNode node)
private ReferenceCaptureIntermediateNode RewriteUsage(IntermediateNode parent, IntermediateToken identifier)
{
// If we can't get a nonempty attribute name, do nothing because there will
// already be a diagnostic for empty values
var identifierToken = DetermineIdentifierToken(node);
if (identifierToken == null)
{
return node;
}
// Determine whether this is an element capture or a component capture, and
// if applicable the type name that will appear in the resulting capture code
var componentTagHelper = (parent as ComponentIntermediateNode)?.Component;
if (componentTagHelper != null)
{
return new ReferenceCaptureIntermediateNode(identifierToken, componentTagHelper.GetTypeName());
return new ReferenceCaptureIntermediateNode(identifier, componentTagHelper.GetTypeName());
}
else
{
return new ReferenceCaptureIntermediateNode(identifierToken);
return new ReferenceCaptureIntermediateNode(identifier);
}
}
private bool ShouldGenerateField(IntermediateNode parent)
{
var parameters = parent.FindDescendantNodes<TagHelperDirectiveAttributeParameterIntermediateNode>();
for (var i = 0; i < parameters.Count; i++)
{
var parameter = parameters[i];
if (parameter.TagHelper.IsRefTagHelper() && parameter.BoundAttributeParameter.Name == "suppressField")
{
if (parameter.HasDiagnostics)
{
parent.Diagnostics.AddRange(parameter.GetAllDiagnostics());
}
parent.Children.Remove(parameter);
if (parameter.AttributeStructure == AttributeStructure.Minimized)
{
return false;
}
// We do not support non-minimized attributes here because we can't allow the value to be dynamic.
// As a design/experience decision, we don't let you write @ref:suppressField="false" even though
// we could parse it. The rationale is that it's misleading, you type something that looks like code,
// but it's not really.
parent.Diagnostics.Add(ComponentDiagnosticFactory.Create_RefSuppressFieldNotMinimized(parameter.Source));
}
}
if (parent is ComponentIntermediateNode component && component.Component.IsGenericTypedComponent())
{
// We cannot automatically generate a 'ref' field for generic components because we don't know
// how to write the type.
parent.Diagnostics.Add(ComponentDiagnosticFactory.Create_RefSuppressFieldRequiredForGeneric(parent.Source));
return false;
}
return true;
}
private IntermediateNode CreateField(string fieldType, IntermediateToken identifier)
{
return new FieldDeclarationIntermediateNode()
{
FieldName = identifier.Content,
FieldType = fieldType,
Modifiers = { "private" },
SuppressWarnings =
{
"0414", // Field is assigned by never used
"0169", // Field is never used
},
};
}
private IntermediateToken DetermineIdentifierToken(TagHelperDirectiveAttributeIntermediateNode attributeNode)
{
IntermediateToken foundToken = null;

View File

@ -1744,14 +1744,6 @@ namespace Microsoft.AspNetCore.Razor.Language
out var parameterMatch,
out var associatedAttributeParameterDescriptor))
{
var expectsBooleanValue = associatedAttributeDescriptor.ExpectsBooleanValue(attributeName);
if (!expectsBooleanValue)
{
// We do not allow minimized non-boolean bound attributes.
return;
}
// Directive attributes should start with '@' unless the descriptors are misconfigured.
// In that case, we would have already logged an error.
var actualAttributeName = attributeName.StartsWith("@") ? attributeName.Substring(1) : attributeName;
@ -1760,6 +1752,13 @@ namespace Microsoft.AspNetCore.Razor.Language
if (parameterMatch &&
TagHelperMatchingConventions.TryGetBoundAttributeParameter(actualAttributeName, out var attributeNameWithoutParameter, out _))
{
var expectsBooleanValue = associatedAttributeParameterDescriptor.IsBooleanProperty;
if (!expectsBooleanValue)
{
// We do not allow minimized non-boolean bound attributes.
return;
}
attributeNode = new TagHelperDirectiveAttributeParameterIntermediateNode()
{
AttributeName = actualAttributeName,
@ -1775,6 +1774,13 @@ namespace Microsoft.AspNetCore.Razor.Language
}
else
{
var expectsBooleanValue = associatedAttributeDescriptor.ExpectsBooleanValue(attributeName);
if (!expectsBooleanValue)
{
// We do not allow minimized non-boolean bound attributes.
return;
}
attributeNode = new TagHelperDirectiveAttributeIntermediateNode()
{
AttributeName = actualAttributeName,

View File

@ -8,12 +8,15 @@ using System.Linq;
using System.Text;
using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
using Microsoft.AspNetCore.Razor.Language.Intermediate;
using Microsoft.AspNetCore.Razor.Language.Legacy;
namespace Microsoft.AspNetCore.Razor.Language.Extensions
{
internal sealed class DefaultTagHelperTargetExtension : IDefaultTagHelperTargetExtension
{
private static readonly string[] FieldUnintializedModifiers = { "0649", };
private static readonly string[] FieldUnusedModifiers = { "0169", };
private static readonly string[] PrivateModifiers = new string[] { "private" };
public string RunnerVariableName { get; set; } = "__tagHelperRunner";
@ -476,9 +479,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
public void WriteTagHelperRuntime(CodeRenderingContext context, DefaultTagHelperRuntimeIntermediateNode node)
{
context.CodeWriter.WriteLine("#line hidden");
context.CodeWriter.WriteLine("#pragma warning disable 0649");
context.CodeWriter.WriteField(PrivateModifiers, ExecutionContextTypeName, ExecutionContextVariableName);
context.CodeWriter.WriteLine("#pragma warning restore 0649");
context.CodeWriter.WriteField(FieldUnintializedModifiers, PrivateModifiers, ExecutionContextTypeName, ExecutionContextVariableName);
context.CodeWriter
.Write("private ")
@ -491,12 +492,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
if (!context.Options.DesignTime)
{
// Need to disable the warning "X is never used." for the value buffer since
// whether it's used depends on how a TagHelper is used.
context.CodeWriter.WriteLine("#pragma warning disable 0169");
context.CodeWriter.WriteField(PrivateModifiers, "string", StringValueBufferVariableName);
context.CodeWriter.WriteLine("#pragma warning restore 0169");
context.CodeWriter.WriteField(FieldUnusedModifiers, PrivateModifiers, "string", StringValueBufferVariableName);
var backedScopeManageVariableName = "__backed" + ScopeManagerVariableName;
context.CodeWriter
.Write("private ")

View File

@ -12,6 +12,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
public IList<string> Modifiers { get; } = new List<string>();
public IList<string> SuppressWarnings { get; } = new List<string>();
public string FieldName { get; set; }
public string FieldType { get; set; }

View File

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
using Microsoft.AspNetCore.Razor.Language.Components;
namespace Microsoft.AspNetCore.Razor.Language.Intermediate
@ -35,7 +34,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
public string ComponentCaptureTypeName { get; set; }
public string TypeName => $"global::System.Action<{(IsComponentCapture ? ComponentCaptureTypeName : "global::" + ComponentsApi.ElementRef.FullTypeName)}>";
public string FieldTypeName => IsComponentCapture ? ComponentCaptureTypeName : "global::" + ComponentsApi.ElementRef.FullTypeName;
public string TypeName => $"global::System.Action<{FieldTypeName}>";
public override void Accept(IntermediateNodeVisitor visitor)
{

View File

@ -62,6 +62,16 @@ namespace Microsoft.AspNetCore.Razor.Language
_inner.AddRange(items);
}
public void AddRange(IEnumerable<RazorDiagnostic> items)
{
if (items == null)
{
throw new ArgumentNullException(nameof(items));
}
_inner.AddRange(items);
}
public void Clear()
{
_inner.Clear();

View File

@ -287,7 +287,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
var writer = new CodeWriter();
// Act
writer.WriteField(new[] { "private" }, "global::System.String", "_myString");
writer.WriteField(Array.Empty<string>(), new[] { "private" }, "global::System.String", "_myString");
// Assert
var output = writer.GenerateCode();
@ -301,13 +301,37 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
var writer = new CodeWriter();
// Act
writer.WriteField(new[] { "private", "readonly", "static" }, "global::System.String", "_myString");
writer.WriteField(Array.Empty<string>(), new[] { "private", "readonly", "static" }, "global::System.String", "_myString");
// Assert
var output = writer.GenerateCode();
Assert.Equal("private readonly static global::System.String _myString;" + Environment.NewLine, output);
}
[Fact]
public void WriteField_WithModifiersAndSupressions_WritesFieldDeclaration()
{
// Arrange
var writer = new CodeWriter();
// Act
writer.WriteField(
new[] { "0001", "0002", },
new[] { "private", "readonly", "static" },
"global::System.String",
"_myString");
// Assert
var output = writer.GenerateCode();
Assert.Equal(
"#pragma warning disable 0001" + Environment.NewLine +
"#pragma warning disable 0002" + Environment.NewLine +
"private readonly static global::System.String _myString;" + Environment.NewLine +
"#pragma warning restore 0002" + Environment.NewLine +
"#pragma warning restore 0001" + Environment.NewLine,
output);
}
[Fact]
public void WriteAutoPropertyDeclaration_WritesPropertyDeclaration()
{

View File

@ -2994,7 +2994,7 @@ namespace Test
}
[Fact]
public void GenericComponent_WithComponentRef()
public void GenericComponent_WithComponentRef_CreatesDiagnostic()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
@ -3012,10 +3012,39 @@ namespace Test
// Act
var generated = CompileToCSharp(@"
<MyComponent TItem=int Item=""3"" @ref=""_my"" />
@code {
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
MyComponent myInstance;
void DoStuff() { GC.KeepAlive(myInstance); }
}
", throwOnFailure: false);
// Assert
var diagnostic = Assert.Single(generated.Diagnostics);
Assert.Same(diagnostic.Id, ComponentDiagnosticFactory.RefSuppressFieldRequiredForGeneric.Id);
}
[Fact]
public void GenericComponent_WithComponentRef_SuppressField()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Components;
namespace Test
{
public class MyComponent<TItem> : ComponentBase
{
[Parameter] public TItem Item { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
<MyComponent TItem=int Item=""3"" @ref=""_my"" @ref:suppressField />
@code {
MyComponent<int> _my;
void DoStuff() { GC.KeepAlive(_my); }
}
");
@ -3026,7 +3055,7 @@ namespace Test
}
[Fact]
public void GenericComponent_WithComponentRef_TypeInference()
public void GenericComponent_WithComponentRef_TypeInference_CreatesDiagnostic()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
@ -3045,6 +3074,38 @@ namespace Test
var generated = CompileToCSharp(@"
<MyComponent Item=""3"" @ref=""_my"" />
@code {
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
}
", throwOnFailure: true);
// Assert
var diagnostic = Assert.Single(generated.Diagnostics);
Assert.Same(diagnostic.Id, ComponentDiagnosticFactory.RefSuppressFieldRequiredForGeneric.Id);
}
[Fact]
public void GenericComponent_WithComponentRef_TypeInference_SuppressField()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Components;
namespace Test
{
public class MyComponent<TItem> : ComponentBase
{
[Parameter] public TItem Item { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
<MyComponent Item=""3"" @ref=""_my"" @ref:suppressField />
@code {
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
@ -3386,13 +3447,7 @@ namespace Test
{
// Arrange/Act
var generated = CompileToCSharp(@"
<elem attributebefore=""before"" @ref=""myElem"" attributeafter=""after"">Hello</elem>
@code {
private Microsoft.AspNetCore.Components.ElementRef myElem;
public void Foo() { System.GC.KeepAlive(myElem); }
}
");
<elem attributebefore=""before"" @ref=""myElem"" attributeafter=""after"">Hello</elem>");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
@ -3408,10 +3463,7 @@ namespace Test
<input type=""text"" data-slider-min=""@Min"" @ref=""@_element"" />
@code {
private ElementRef _element;
[Parameter] protected int Min { get; set; }
public void Foo() { System.GC.KeepAlive(_element); }
}
");
@ -3421,6 +3473,35 @@ namespace Test
CompileToAssembly(generated);
}
[Fact]
public void Element_WithRef_SuppressField()
{
// Arrange/Act
var generated = CompileToCSharp(@"
<elem @ref=""myElem"" @ref:suppressField>Hello</elem>
@code {
ElementRef myElem;
void DoStuff() { GC.KeepAlive(myElem); }
}");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact]
public void Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic()
{
// Arrange/Act
var generated = CompileToCSharp(@"
<elem @ref=""myElem"" @ref:suppressField=""false"">Hello</elem>", throwOnFailure: false);
// Assert
var diagnostic = Assert.Single(generated.Diagnostics);
Assert.Same(diagnostic.Id, ComponentDiagnosticFactory.RefSuppressFieldNotMinimized.Id);
}
[Fact]
public void Component_WithRef()
{
@ -3438,13 +3519,7 @@ namespace Test
// Arrange/Act
var generated = CompileToCSharp(@"
<MyComponent ParamBefore=""before"" @ref=""myInstance"" ParamAfter=""after"" />
@code {
private Test.MyComponent myInstance;
public void Foo() { System.GC.KeepAlive(myInstance); }
}
");
<MyComponent ParamBefore=""before"" @ref=""myInstance"" ParamAfter=""after"" />");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
@ -3472,11 +3547,6 @@ namespace Test
<MyComponent @ref=""myInstance"" SomeProp=""val"">
Some <el>further</el> content
</MyComponent>
@code {
private Test.MyComponent myInstance;
public void Foo() { System.GC.KeepAlive(myInstance); }
}
");
// Assert
@ -3485,6 +3555,35 @@ namespace Test
CompileToAssembly(generated);
}
[Fact]
public void Component_WithRef_SuppressField()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using Microsoft.AspNetCore.Components;
namespace Test
{
public class MyComponent : ComponentBase
{
}
}
"));
// Arrange/Act
var generated = CompileToCSharp(@"
<MyComponent @ref=""myInstance"" @ref:suppressField />
@code {
MyComponent myInstance;
void DoStuff() { GC.KeepAlive(myInstance); }
}");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
#endregion
#region Templates

View File

@ -10,6 +10,11 @@ namespace Test
using Microsoft.AspNetCore.Components;
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 0414
#pragma warning disable 0169
private Test.MyComponent myInstance;
#pragma warning restore 0169
#pragma warning restore 0414
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
}
@ -41,15 +46,6 @@ __o = typeof(MyComponent);
#nullable disable
}
#pragma warning restore 1998
#nullable restore
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
private Test.MyComponent myInstance;
public void Foo() { System.GC.KeepAlive(myInstance); }
#line default
#line hidden
#nullable disable
}
}
#pragma warning restore 1591

View File

@ -6,6 +6,7 @@ Document -
UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
FieldDeclaration - - private - Test.MyComponent - myInstance
DesignTimeDirective -
CSharpCode -
IntermediateToken - - CSharp - #pragma warning disable 0414
@ -22,9 +23,3 @@ Document -
ComponentAttribute - - ParamAfter - AttributeStructure.DoubleQuotes
HtmlContent - (64:0,64 [5] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (64:0,64 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - after
HtmlContent - (73:0,73 [4] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (73:0,73 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
HtmlContent - (189:5,1 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (189:5,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (84:2,7 [104] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (84:2,7 [104] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private Test.MyComponent myInstance;\n public void Foo() { System.GC.KeepAlive(myInstance); }\n

View File

@ -1,16 +1,5 @@
Source Location: (40:0,40 [10] x:\dir\subdir\Test\TestComponent.cshtml)
|myInstance|
Generated Location: (1080:29,40 [10] )
Generated Location: (1278:34,40 [10] )
|myInstance|
Source Location: (84:2,7 [104] x:\dir\subdir\Test\TestComponent.cshtml)
|
private Test.MyComponent myInstance;
public void Foo() { System.GC.KeepAlive(myInstance); }
|
Generated Location: (1445:45,7 [104] )
|
private Test.MyComponent myInstance;
public void Foo() { System.GC.KeepAlive(myInstance); }
|

View File

@ -0,0 +1,53 @@
// <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)
{
builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((builder2) => {
}
));
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
myInstance = default(Test.MyComponent);
#line default
#line hidden
#nullable disable
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
__o = typeof(MyComponent);
#line default
#line hidden
#nullable disable
}
#pragma warning restore 1998
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
MyComponent myInstance;
void DoStuff() { GC.KeepAlive(myInstance); }
#line default
#line hidden
#nullable disable
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,22 @@
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
Component - (0:0,0 [52] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
ReferenceCapture - (19:0,19 [10] x:\dir\subdir\Test\TestComponent.cshtml) - myInstance
HtmlContent - (52:0,52 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (52:0,52 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (61:1,7 [81] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (61:1,7 [81] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n MyComponent myInstance;\n void DoStuff() { GC.KeepAlive(myInstance); }\n

View File

@ -0,0 +1,16 @@
Source Location: (19:0,19 [10] x:\dir\subdir\Test\TestComponent.cshtml)
|myInstance|
Generated Location: (1013:27,19 [10] )
|myInstance|
Source Location: (61:1,7 [81] x:\dir\subdir\Test\TestComponent.cshtml)
|
MyComponent myInstance;
void DoStuff() { GC.KeepAlive(myInstance); }
|
Generated Location: (1378:43,7 [81] )
|
MyComponent myInstance;
void DoStuff() { GC.KeepAlive(myInstance); }
|

View File

@ -10,6 +10,11 @@ namespace Test
using Microsoft.AspNetCore.Components;
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 0414
#pragma warning disable 0169
private Test.MyComponent myInstance;
#pragma warning restore 0169
#pragma warning restore 0414
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
}
@ -40,15 +45,6 @@ __o = typeof(MyComponent);
#nullable disable
}
#pragma warning restore 1998
#nullable restore
#line 5 "x:\dir\subdir\Test\TestComponent.cshtml"
private Test.MyComponent myInstance;
public void Foo() { System.GC.KeepAlive(myInstance); }
#line default
#line hidden
#nullable disable
}
}
#pragma warning restore 1591

View File

@ -6,6 +6,7 @@ Document -
UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
FieldDeclaration - - private - Test.MyComponent - myInstance
DesignTimeDirective -
CSharpCode -
IntermediateToken - - CSharp - #pragma warning disable 0414
@ -27,9 +28,5 @@ Document -
ComponentAttribute - - SomeProp - AttributeStructure.DoubleQuotes
HtmlContent - (41:0,41 [3] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (41:0,41 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - val
HtmlContent - (97:2,14 [4] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (97:2,14 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
HtmlContent - (213:7,1 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (213:7,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (108:4,7 [104] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (108:4,7 [104] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private Test.MyComponent myInstance;\n public void Foo() { System.GC.KeepAlive(myInstance); }\n
HtmlContent - (97:2,14 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (97:2,14 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n

View File

@ -1,16 +1,5 @@
Source Location: (19:0,19 [10] x:\dir\subdir\Test\TestComponent.cshtml)
|myInstance|
Generated Location: (1036:28,19 [10] )
Generated Location: (1234:33,19 [10] )
|myInstance|
Source Location: (108:4,7 [104] x:\dir\subdir\Test\TestComponent.cshtml)
|
private Test.MyComponent myInstance;
public void Foo() { System.GC.KeepAlive(myInstance); }
|
Generated Location: (1401:44,7 [104] )
|
private Test.MyComponent myInstance;
public void Foo() { System.GC.KeepAlive(myInstance); }
|

View File

@ -10,6 +10,11 @@ namespace Test
using Microsoft.AspNetCore.Components;
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 0414
#pragma warning disable 0169
private global::Microsoft.AspNetCore.Components.ElementRef myElem;
#pragma warning restore 0169
#pragma warning restore 0414
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
}
@ -29,15 +34,6 @@ namespace Test
#nullable disable
}
#pragma warning restore 1998
#nullable restore
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
private Microsoft.AspNetCore.Components.ElementRef myElem;
public void Foo() { System.GC.KeepAlive(myElem); }
#line default
#line hidden
#nullable disable
}
}
#pragma warning restore 1591

View File

@ -6,6 +6,7 @@ Document -
UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
FieldDeclaration - - private - global::Microsoft.AspNetCore.Components.ElementRef - myElem
DesignTimeDirective -
CSharpCode -
IntermediateToken - - CSharp - #pragma warning disable 0414
@ -24,9 +25,3 @@ Document -
HtmlAttribute - - attributeafter=" - "
HtmlAttributeValue - (61:0,61 [5] x:\dir\subdir\Test\TestComponent.cshtml) -
IntermediateToken - (61:0,61 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - after
HtmlContent - (80:0,80 [4] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (80:0,80 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
HtmlContent - (214:5,1 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (214:5,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (91:2,7 [122] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (91:2,7 [122] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private Microsoft.AspNetCore.Components.ElementRef myElem;\n public void Foo() { System.GC.KeepAlive(myElem); }\n

View File

@ -1,16 +1,5 @@
Source Location: (37:0,37 [6] x:\dir\subdir\Test\TestComponent.cshtml)
|myElem|
Generated Location: (880:24,37 [6] )
Generated Location: (1108:29,37 [6] )
|myElem|
Source Location: (91:2,7 [122] x:\dir\subdir\Test\TestComponent.cshtml)
|
private Microsoft.AspNetCore.Components.ElementRef myElem;
public void Foo() { System.GC.KeepAlive(myElem); }
|
Generated Location: (1119:33,7 [122] )
|
private Microsoft.AspNetCore.Components.ElementRef myElem;
public void Foo() { System.GC.KeepAlive(myElem); }
|

View File

@ -10,6 +10,11 @@ namespace Test
using Microsoft.AspNetCore.Components;
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 0414
#pragma warning disable 0169
private global::Microsoft.AspNetCore.Components.ElementRef _element;
#pragma warning restore 0169
#pragma warning restore 0414
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
}
@ -41,10 +46,7 @@ namespace Test
#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

View File

@ -6,6 +6,7 @@ Document -
UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
FieldDeclaration - - private - global::Microsoft.AspNetCore.Components.ElementRef - _element
DesignTimeDirective -
CSharpCode -
IntermediateToken - - CSharp - #pragma warning disable 0414
@ -24,7 +25,7 @@ Document -
ReferenceCapture - (49:0,49 [8] x:\dir\subdir\Test\TestComponent.cshtml) - _element
HtmlContent - (61:0,61 [4] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (61:0,61 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
HtmlContent - (234:7,5 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (234:7,5 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (72:2,7 [161] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (72:2,7 [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
HtmlContent - (132:4,5 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (132:4,5 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (72:2,7 [59] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (72:2,7 [59] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n [Parameter] protected int Min { get; set; }\n

View File

@ -1,25 +1,19 @@
Source Location: (37:0,37 [3] x:\dir\subdir\Test\TestComponent.cshtml)
|Min|
Generated Location: (900:25,37 [3] )
Generated Location: (1130:30,37 [3] )
|Min|
Source Location: (49:0,49 [8] x:\dir\subdir\Test\TestComponent.cshtml)
|_element|
Generated Location: (1089:33,49 [8] )
Generated Location: (1319:38,49 [8] )
|_element|
Source Location: (72:2,7 [161] x:\dir\subdir\Test\TestComponent.cshtml)
Source Location: (72:2,7 [59] x:\dir\subdir\Test\TestComponent.cshtml)
|
private ElementRef _element;
[Parameter] protected int Min { get; set; }
public void Foo() { System.GC.KeepAlive(_element); }
|
Generated Location: (1330:42,7 [161] )
Generated Location: (1560:47,7 [59] )
|
private ElementRef _element;
[Parameter] protected int Min { get; set; }
public void Foo() { System.GC.KeepAlive(_element); }
|

View File

@ -0,0 +1,43 @@
// <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)
{
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
myElem = default(Microsoft.AspNetCore.Components.ElementRef);
#line default
#line hidden
#nullable disable
}
#pragma warning restore 1998
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
ElementRef myElem;
void DoStuff() { GC.KeepAlive(myElem); }
#line default
#line hidden
#nullable disable
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,24 @@
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 [51] x:\dir\subdir\Test\TestComponent.cshtml) - elem
HtmlContent - (39:0,39 [5] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (39:0,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello
ReferenceCapture - (12:0,12 [6] x:\dir\subdir\Test\TestComponent.cshtml) - myElem
HtmlContent - (51:0,51 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (51:0,51 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (60:1,7 [72] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (60:1,7 [72] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n ElementRef myElem;\n void DoStuff() { GC.KeepAlive(myElem); }\n

View File

@ -0,0 +1,16 @@
Source Location: (12:0,12 [6] x:\dir\subdir\Test\TestComponent.cshtml)
|myElem|
Generated Location: (855:24,12 [6] )
|myElem|
Source Location: (60:1,7 [72] x:\dir\subdir\Test\TestComponent.cshtml)
|
ElementRef myElem;
void DoStuff() { GC.KeepAlive(myElem); }
|
Generated Location: (1094:33,7 [72] )
|
ElementRef myElem;
void DoStuff() { GC.KeepAlive(myElem); }
|

View File

@ -0,0 +1,39 @@
// <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 0414
#pragma warning disable 0169
private global::Microsoft.AspNetCore.Components.ElementRef myElem;
#pragma warning restore 0169
#pragma warning restore 0414
#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)
{
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
myElem = default(Microsoft.AspNetCore.Components.ElementRef);
#line default
#line hidden
#nullable disable
}
#pragma warning restore 1998
}
}
#pragma warning restore 1591

View File

@ -0,0 +1 @@
x:\dir\subdir\Test\TestComponent.cshtml(1,41): Error RZ10011: The directive attribute '@ref:suppressField' must be used as a minimized attribute. Providing an attribute value like '@ref:suppressField="false" is not supported.

View File

@ -0,0 +1,21 @@
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 -
FieldDeclaration - - private - global::Microsoft.AspNetCore.Components.ElementRef - myElem
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 [59] x:\dir\subdir\Test\TestComponent.cshtml) - elem
HtmlContent - (47:0,47 [5] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (47:0,47 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello
ReferenceCapture - (12:0,12 [6] x:\dir\subdir\Test\TestComponent.cshtml) - myElem

View File

@ -0,0 +1,5 @@
Source Location: (12:0,12 [6] x:\dir\subdir\Test\TestComponent.cshtml)
|myElem|
Generated Location: (1083:29,12 [6] )
|myElem|

View File

@ -58,10 +58,10 @@ __o = typeof(MyComponent<>);
}
#pragma warning restore 1998
#nullable restore
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
MyComponent<int> _my;
void DoStuff() { GC.KeepAlive(_my); }
#line default
#line hidden

View File

@ -14,15 +14,15 @@ Document -
CSharpCode -
IntermediateToken - - CSharp - #pragma warning restore 0414
MethodDeclaration - - protected override - void - BuildRenderTree
Component - (0:0,0 [45] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
Component - (0:0,0 [64] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
ComponentTypeArgument - (19:0,19 [3] x:\dir\subdir\Test\TestComponent.cshtml) - TItem
IntermediateToken - (19:0,19 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - int
ComponentAttribute - (29:0,29 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Item - AttributeStructure.DoubleQuotes
IntermediateToken - (29:0,29 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 3
ReferenceCapture - (38:0,38 [3] x:\dir\subdir\Test\TestComponent.cshtml) - _my
HtmlContent - (45:0,45 [4] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (45:0,45 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
HtmlContent - (147:5,1 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (147:5,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (56:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (56:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private MyComponent<int> _my;\n public void Foo() { System.GC.KeepAlive(_my); }\n
HtmlContent - (64:0,64 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (64:0,64 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
HtmlContent - (146:4,1 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (146:4,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (73:1,7 [72] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (73:1,7 [72] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n MyComponent<int> _my;\n void DoStuff() { GC.KeepAlive(_my); }\n

View File

@ -13,14 +13,14 @@ Source Location: (38:0,38 [3] x:\dir\subdir\Test\TestComponent.cshtml)
Generated Location: (1469:45,38 [3] )
|_my|
Source Location: (56:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml)
Source Location: (73:1,7 [72] x:\dir\subdir\Test\TestComponent.cshtml)
|
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
MyComponent<int> _my;
void DoStuff() { GC.KeepAlive(_my); }
|
Generated Location: (1834:61,7 [90] )
Generated Location: (1834:61,7 [72] )
|
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
MyComponent<int> _my;
void DoStuff() { GC.KeepAlive(_my); }
|

View File

@ -14,16 +14,16 @@ Document -
CSharpCode -
IntermediateToken - - CSharp - #pragma warning restore 0414
MethodDeclaration - - protected override - void - BuildRenderTree
Component - (0:0,0 [35] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
Component - (0:0,0 [54] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
ComponentAttribute - (19:0,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Item - AttributeStructure.DoubleQuotes
IntermediateToken - (19:0,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 3
ReferenceCapture - (28:0,28 [3] x:\dir\subdir\Test\TestComponent.cshtml) - _my
HtmlContent - (35:0,35 [4] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (35:0,35 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
HtmlContent - (137:5,1 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (137:5,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (46:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (46:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private MyComponent<int> _my;\n public void Foo() { System.GC.KeepAlive(_my); }\n
HtmlContent - (54:0,54 [4] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (54:0,54 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
HtmlContent - (156:5,1 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (156:5,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (65:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (65:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private MyComponent<int> _my;\n public void Foo() { System.GC.KeepAlive(_my); }\n
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

View File

@ -8,7 +8,7 @@ Source Location: (28:0,28 [3] x:\dir\subdir\Test\TestComponent.cshtml)
Generated Location: (1140:33,28 [3] )
|_my|
Source Location: (46:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml)
Source Location: (65:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml)
|
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }

View File

@ -10,6 +10,11 @@ namespace Test
using Microsoft.AspNetCore.Components;
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 0414
#pragma warning disable 0169
private Test.MyComponent myInstance;
#pragma warning restore 0169
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder)
{
@ -29,15 +34,6 @@ namespace Test
builder.CloseComponent();
}
#pragma warning restore 1998
#nullable restore
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
private Test.MyComponent myInstance;
public void Foo() { System.GC.KeepAlive(myInstance); }
#line default
#line hidden
#nullable disable
}
}
#pragma warning restore 1591

View File

@ -6,6 +6,7 @@ Document -
UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
FieldDeclaration - - private - Test.MyComponent - myInstance
MethodDeclaration - - protected override - void - BuildRenderTree
Component - (0:0,0 [73] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
ComponentAttribute - - ParamBefore - AttributeStructure.DoubleQuotes
@ -15,5 +16,3 @@ Document -
ComponentAttribute - - ParamAfter - AttributeStructure.DoubleQuotes
HtmlContent - (64:0,64 [5] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (64:0,64 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - after
CSharpCode - (84:2,7 [104] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (84:2,7 [104] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private Test.MyComponent myInstance;\n public void Foo() { System.GC.KeepAlive(myInstance); }\n

View File

@ -1,16 +1,5 @@
Source Location: (40:0,40 [10] x:\dir\subdir\Test\TestComponent.cshtml)
|myInstance|
Generated Location: (864:21,40 [10] )
Generated Location: (1062:26,40 [10] )
|myInstance|
Source Location: (84:2,7 [104] x:\dir\subdir\Test\TestComponent.cshtml)
|
private Test.MyComponent myInstance;
public void Foo() { System.GC.KeepAlive(myInstance); }
|
Generated Location: (1151:33,7 [104] )
|
private Test.MyComponent myInstance;
public void Foo() { System.GC.KeepAlive(myInstance); }
|

View File

@ -0,0 +1,41 @@
// <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.OpenComponent<Test.MyComponent>(0);
builder.AddComponentReferenceCapture(1, (__value) => {
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
myInstance = (Test.MyComponent)__value;
#line default
#line hidden
#nullable disable
}
);
builder.CloseComponent();
}
#pragma warning restore 1998
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
MyComponent myInstance;
void DoStuff() { GC.KeepAlive(myInstance); }
#line default
#line hidden
#nullable disable
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,13 @@
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
Component - (0:0,0 [52] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
ReferenceCapture - (19:0,19 [10] x:\dir\subdir\Test\TestComponent.cshtml) - myInstance
CSharpCode - (61:1,7 [81] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (61:1,7 [81] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n MyComponent myInstance;\n void DoStuff() { GC.KeepAlive(myInstance); }\n

View File

@ -0,0 +1,16 @@
Source Location: (19:0,19 [10] x:\dir\subdir\Test\TestComponent.cshtml)
|myInstance|
Generated Location: (719:19,19 [10] )
|myInstance|
Source Location: (61:1,7 [81] x:\dir\subdir\Test\TestComponent.cshtml)
|
MyComponent myInstance;
void DoStuff() { GC.KeepAlive(myInstance); }
|
Generated Location: (1006:31,7 [81] )
|
MyComponent myInstance;
void DoStuff() { GC.KeepAlive(myInstance); }
|

View File

@ -10,6 +10,11 @@ namespace Test
using Microsoft.AspNetCore.Components;
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 0414
#pragma warning disable 0169
private Test.MyComponent myInstance;
#pragma warning restore 0169
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder)
{
@ -33,15 +38,6 @@ namespace Test
builder.CloseComponent();
}
#pragma warning restore 1998
#nullable restore
#line 5 "x:\dir\subdir\Test\TestComponent.cshtml"
private Test.MyComponent myInstance;
public void Foo() { System.GC.KeepAlive(myInstance); }
#line default
#line hidden
#nullable disable
}
}
#pragma warning restore 1591

View File

@ -6,6 +6,7 @@ Document -
UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
FieldDeclaration - - private - Test.MyComponent - myInstance
MethodDeclaration - - protected override - void - BuildRenderTree
Component - (0:0,0 [97] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
ComponentChildContent - - ChildContent - context
@ -16,5 +17,3 @@ Document -
ComponentAttribute - - SomeProp - AttributeStructure.DoubleQuotes
HtmlContent - (41:0,41 [3] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (41:0,41 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - val
CSharpCode - (108:4,7 [104] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (108:4,7 [104] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private Test.MyComponent myInstance;\n public void Foo() { System.GC.KeepAlive(myInstance); }\n

View File

@ -1,16 +1,5 @@
Source Location: (19:0,19 [10] x:\dir\subdir\Test\TestComponent.cshtml)
|myInstance|
Generated Location: (1069:27,19 [10] )
Generated Location: (1267:32,19 [10] )
|myInstance|
Source Location: (108:4,7 [104] x:\dir\subdir\Test\TestComponent.cshtml)
|
private Test.MyComponent myInstance;
public void Foo() { System.GC.KeepAlive(myInstance); }
|
Generated Location: (1356:39,7 [104] )
|
private Test.MyComponent myInstance;
public void Foo() { System.GC.KeepAlive(myInstance); }
|

View File

@ -10,6 +10,11 @@ namespace Test
using Microsoft.AspNetCore.Components;
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 0414
#pragma warning disable 0169
private global::Microsoft.AspNetCore.Components.ElementRef myElem;
#pragma warning restore 0169
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder)
{
@ -30,15 +35,6 @@ namespace Test
builder.CloseElement();
}
#pragma warning restore 1998
#nullable restore
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
private Microsoft.AspNetCore.Components.ElementRef myElem;
public void Foo() { System.GC.KeepAlive(myElem); }
#line default
#line hidden
#nullable disable
}
}
#pragma warning restore 1591

View File

@ -6,6 +6,7 @@ Document -
UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
FieldDeclaration - - private - global::Microsoft.AspNetCore.Components.ElementRef - myElem
MethodDeclaration - - protected override - void - BuildRenderTree
MarkupElement - (0:0,0 [80] x:\dir\subdir\Test\TestComponent.cshtml) - elem
HtmlContent - (68:0,68 [5] x:\dir\subdir\Test\TestComponent.cshtml)
@ -17,5 +18,3 @@ Document -
HtmlAttribute - - attributeafter=" - "
HtmlAttributeValue - (61:0,61 [5] x:\dir\subdir\Test\TestComponent.cshtml) -
IntermediateToken - (61:0,61 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - after
CSharpCode - (91:2,7 [122] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (91:2,7 [122] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private Microsoft.AspNetCore.Components.ElementRef myElem;\n public void Foo() { System.GC.KeepAlive(myElem); }\n

View File

@ -1,16 +1,5 @@
Source Location: (37:0,37 [6] x:\dir\subdir\Test\TestComponent.cshtml)
|myElem|
Generated Location: (855:21,37 [6] )
Generated Location: (1083:26,37 [6] )
|myElem|
Source Location: (91:2,7 [122] x:\dir\subdir\Test\TestComponent.cshtml)
|
private Microsoft.AspNetCore.Components.ElementRef myElem;
public void Foo() { System.GC.KeepAlive(myElem); }
|
Generated Location: (1163:34,7 [122] )
|
private Microsoft.AspNetCore.Components.ElementRef myElem;
public void Foo() { System.GC.KeepAlive(myElem); }
|

View File

@ -10,6 +10,11 @@ namespace Test
using Microsoft.AspNetCore.Components;
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 0414
#pragma warning disable 0169
private global::Microsoft.AspNetCore.Components.ElementRef _element;
#pragma warning restore 0169
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder)
{
@ -40,10 +45,7 @@ namespace Test
#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

View File

@ -6,6 +6,7 @@ Document -
UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
FieldDeclaration - - private - global::Microsoft.AspNetCore.Components.ElementRef - _element
MethodDeclaration - - protected override - void - BuildRenderTree
MarkupElement - (0:0,0 [61] x:\dir\subdir\Test\TestComponent.cshtml) - input
HtmlAttribute - - type=" - "
@ -15,5 +16,5 @@ Document -
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 - (49:0,49 [8] x:\dir\subdir\Test\TestComponent.cshtml) - _element
CSharpCode - (72:2,7 [161] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (72:2,7 [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
CSharpCode - (72:2,7 [59] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (72:2,7 [59] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n [Parameter] protected int Min { get; set; }\n

View File

@ -1,20 +1,14 @@
Source Location: (49:0,49 [8] x:\dir\subdir\Test\TestComponent.cshtml)
|_element|
Generated Location: (1025:29,49 [8] )
Generated Location: (1255:34,49 [8] )
|_element|
Source Location: (72:2,7 [161] x:\dir\subdir\Test\TestComponent.cshtml)
Source Location: (72:2,7 [59] x:\dir\subdir\Test\TestComponent.cshtml)
|
private ElementRef _element;
[Parameter] protected int Min { get; set; }
public void Foo() { System.GC.KeepAlive(_element); }
|
Generated Location: (1290:41,7 [161] )
Generated Location: (1520:46,7 [59] )
|
private ElementRef _element;
[Parameter] protected int Min { get; set; }
public void Foo() { System.GC.KeepAlive(_element); }
|

View File

@ -0,0 +1,42 @@
// <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, "elem");
builder.AddElementReferenceCapture(1, (__value) => {
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
myElem = __value;
#line default
#line hidden
#nullable disable
}
);
builder.AddContent(2, "Hello");
builder.CloseElement();
}
#pragma warning restore 1998
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
ElementRef myElem;
void DoStuff() { GC.KeepAlive(myElem); }
#line default
#line hidden
#nullable disable
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,15 @@
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 [51] x:\dir\subdir\Test\TestComponent.cshtml) - elem
HtmlContent - (39:0,39 [5] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (39:0,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello
ReferenceCapture - (12:0,12 [6] x:\dir\subdir\Test\TestComponent.cshtml) - myElem
CSharpCode - (60:1,7 [72] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (60:1,7 [72] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n ElementRef myElem;\n void DoStuff() { GC.KeepAlive(myElem); }\n

View File

@ -0,0 +1,16 @@
Source Location: (12:0,12 [6] x:\dir\subdir\Test\TestComponent.cshtml)
|myElem|
Generated Location: (698:19,12 [6] )
|myElem|
Source Location: (60:1,7 [72] x:\dir\subdir\Test\TestComponent.cshtml)
|
ElementRef myElem;
void DoStuff() { GC.KeepAlive(myElem); }
|
Generated Location: (1006:32,7 [72] )
|
ElementRef myElem;
void DoStuff() { GC.KeepAlive(myElem); }
|

View File

@ -0,0 +1,38 @@
// <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 0414
#pragma warning disable 0169
private global::Microsoft.AspNetCore.Components.ElementRef myElem;
#pragma warning restore 0169
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder)
{
builder.OpenElement(0, "elem");
builder.AddElementReferenceCapture(1, (__value) => {
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
myElem = __value;
#line default
#line hidden
#nullable disable
}
);
builder.AddContent(2, "Hello");
builder.CloseElement();
}
#pragma warning restore 1998
}
}
#pragma warning restore 1591

View File

@ -0,0 +1 @@
x:\dir\subdir\Test\TestComponent.cshtml(1,41): Error RZ10011: The directive attribute '@ref:suppressField' must be used as a minimized attribute. Providing an attribute value like '@ref:suppressField="false" is not supported.

View File

@ -0,0 +1,14 @@
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 -
FieldDeclaration - - private - global::Microsoft.AspNetCore.Components.ElementRef - myElem
MethodDeclaration - - protected override - void - BuildRenderTree
MarkupElement - (0:0,0 [59] x:\dir\subdir\Test\TestComponent.cshtml) - elem
HtmlContent - (47:0,47 [5] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (47:0,47 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello
ReferenceCapture - (12:0,12 [6] x:\dir\subdir\Test\TestComponent.cshtml) - myElem

View File

@ -0,0 +1,5 @@
Source Location: (12:0,12 [6] x:\dir\subdir\Test\TestComponent.cshtml)
|myElem|
Generated Location: (926:24,12 [6] )
|myElem|

View File

@ -10,6 +10,11 @@ namespace Test
using Microsoft.AspNetCore.Components;
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 0414
#pragma warning disable 0169
private Test.MyComponent<TItem> _my;
#pragma warning restore 0169
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder)
{
@ -36,15 +41,6 @@ namespace Test
builder.CloseComponent();
}
#pragma warning restore 1998
#nullable restore
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
#line default
#line hidden
#nullable disable
}
}
#pragma warning restore 1591

View File

@ -6,6 +6,7 @@ Document -
UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
FieldDeclaration - - private - Test.MyComponent<TItem> - _my
MethodDeclaration - - protected override - void - BuildRenderTree
Component - (0:0,0 [45] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
ComponentTypeArgument - (19:0,19 [3] x:\dir\subdir\Test\TestComponent.cshtml) - TItem
@ -13,5 +14,3 @@ Document -
ComponentAttribute - (29:0,29 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Item - AttributeStructure.DoubleQuotes
IntermediateToken - (29:0,29 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 3
ReferenceCapture - (38:0,38 [3] x:\dir\subdir\Test\TestComponent.cshtml) - _my
CSharpCode - (56:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (56:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private MyComponent<int> _my;\n public void Foo() { System.GC.KeepAlive(_my); }\n

View File

@ -1,16 +1,5 @@
Source Location: (38:0,38 [3] x:\dir\subdir\Test\TestComponent.cshtml)
|_my|
Generated Location: (1020:28,38 [3] )
Generated Location: (1218:33,38 [3] )
|_my|
Source Location: (56:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml)
|
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
|
Generated Location: (1305:40,7 [90] )
|
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
|

View File

@ -0,0 +1,50 @@
// <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.OpenComponent<Test.MyComponent<int>>(0);
builder.AddAttribute(1, "Item", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck<int>(
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
3
#line default
#line hidden
#nullable disable
));
builder.AddComponentReferenceCapture(2, (__value) => {
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
_my = (Test.MyComponent<int>)__value;
#line default
#line hidden
#nullable disable
}
);
builder.CloseComponent();
}
#pragma warning restore 1998
#nullable restore
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
MyComponent<int> _my;
void DoStuff() { GC.KeepAlive(_my); }
#line default
#line hidden
#nullable disable
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,17 @@
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
Component - (0:0,0 [64] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
ComponentTypeArgument - (19:0,19 [3] x:\dir\subdir\Test\TestComponent.cshtml) - TItem
IntermediateToken - (19:0,19 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - int
ComponentAttribute - (29:0,29 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Item - AttributeStructure.DoubleQuotes
IntermediateToken - (29:0,29 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 3
ReferenceCapture - (38:0,38 [3] x:\dir\subdir\Test\TestComponent.cshtml) - _my
CSharpCode - (73:1,7 [72] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (73:1,7 [72] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n MyComponent<int> _my;\n void DoStuff() { GC.KeepAlive(_my); }\n

View File

@ -0,0 +1,16 @@
Source Location: (38:0,38 [3] x:\dir\subdir\Test\TestComponent.cshtml)
|_my|
Generated Location: (1020:28,38 [3] )
|_my|
Source Location: (73:1,7 [72] x:\dir\subdir\Test\TestComponent.cshtml)
|
MyComponent<int> _my;
void DoStuff() { GC.KeepAlive(_my); }
|
Generated Location: (1305:40,7 [72] )
|
MyComponent<int> _my;
void DoStuff() { GC.KeepAlive(_my); }
|

View File

@ -10,6 +10,11 @@ namespace Test
using Microsoft.AspNetCore.Components;
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
{
#pragma warning disable 0414
#pragma warning disable 0169
private Test.MyComponent<TItem> _my;
#pragma warning restore 0169
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder)
{

View File

@ -6,6 +6,7 @@ Document -
UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
FieldDeclaration - - private - Test.MyComponent<TItem> - _my
MethodDeclaration - - protected override - void - BuildRenderTree
Component - (0:0,0 [35] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
ComponentAttribute - (19:0,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Item - AttributeStructure.DoubleQuotes

View File

@ -1,6 +1,6 @@
Source Location: (28:0,28 [3] x:\dir\subdir\Test\TestComponent.cshtml)
|_my|
Generated Location: (869:26,28 [3] )
Generated Location: (1067:31,28 [3] )
|_my|
Source Location: (46:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml)
@ -8,7 +8,7 @@ Source Location: (46:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml)
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
|
Generated Location: (1092:37,7 [90] )
Generated Location: (1290:42,7 [90] )
|
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }

View File

@ -0,0 +1,61 @@
// <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)
{
__Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, 0, 1,
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
3
#line default
#line hidden
#nullable disable
, 2, (__value) => {
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
_my = __value;
#line default
#line hidden
#nullable disable
}
);
}
#pragma warning restore 1998
#nullable restore
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
#line default
#line hidden
#nullable disable
}
}
namespace __Blazor.Test.TestComponent
{
#line hidden
internal static class TypeInference
{
public static void CreateMyComponent_0<TItem>(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::System.Action<global::Test.MyComponent<TItem>> __arg1)
{
builder.OpenComponent<global::Test.MyComponent<TItem>>(seq);
builder.AddAttribute(__seq0, "Item", __arg0);
builder.AddComponentReferenceCapture(__seq1, (__value) => { __arg1((global::Test.MyComponent<TItem>)__value); });
builder.CloseComponent();
}
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,18 @@
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
Component - (0:0,0 [54] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
ComponentAttribute - (19:0,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - Item - AttributeStructure.DoubleQuotes
IntermediateToken - (19:0,19 [1] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - 3
ReferenceCapture - (28:0,28 [3] x:\dir\subdir\Test\TestComponent.cshtml) - _my
CSharpCode - (65:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (65:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private MyComponent<int> _my;\n public void Foo() { System.GC.KeepAlive(_my); }\n
NamespaceDeclaration - - __Blazor.Test.TestComponent
ClassDeclaration - - internal static - TypeInference - -
ComponentTypeInferenceMethod - - __Blazor.Test.TestComponent.TypeInference - CreateMyComponent_0

View File

@ -0,0 +1,16 @@
Source Location: (28:0,28 [3] x:\dir\subdir\Test\TestComponent.cshtml)
|_my|
Generated Location: (869:26,28 [3] )
|_my|
Source Location: (65:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml)
|
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
|
Generated Location: (1092:37,7 [90] )
|
private MyComponent<int> _my;
public void Foo() { System.GC.KeepAlive(_my); }
|

View File

@ -61,16 +61,24 @@ namespace Microsoft.CodeAnalysis.Razor
});
});
builder.BindAttribute(attribute =>
builder.BindAttribute(@ref =>
{
attribute.Documentation = ComponentResources.RefTagHelper_Documentation;
attribute.Name = "@ref";
@ref.Documentation = ComponentResources.RefTagHelper_Documentation;
@ref.Name = "@ref";
// WTE has a bug 15.7p1 where a Tag Helper without a display-name that looks like
// a C# property will crash trying to create the tooltips.
attribute.SetPropertyName("Ref");
attribute.TypeName = typeof(object).FullName;
attribute.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString;
@ref.SetPropertyName("Ref");
@ref.TypeName = typeof(object).FullName;
@ref.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString;
@ref.BindAttributeParameter(suppressField =>
{
suppressField.Name = "suppressField";
suppressField.Documentation = ComponentResources.RefTagHelper_SuppressField_Documentation;
suppressField.TypeName = typeof(bool).FullName;
suppressField.SetPropertyName("SuppressField");
});
});
return builder.Build();

View File

@ -38,7 +38,7 @@ namespace Microsoft.CodeAnalysis.Razor
Assert.False(item.IsComponentOrChildContentTagHelper());
Assert.Equal(
"Populates the specified field or property with a reference to the element or component.",
"Generates the specified field, and populates it during rendering with a reference to the element or component.",
item.Documentation);
Assert.Equal("Microsoft.AspNetCore.Components", item.AssemblyName);
@ -74,7 +74,7 @@ namespace Microsoft.CodeAnalysis.Razor
Assert.False(attribute.IsIndexerStringProperty);
Assert.Equal(
"Populates the specified field or property with a reference to the element or component.",
"Generates the specified field, and populates it during rendering with a reference to the element or component.",
attribute.Documentation);
Assert.Equal("@ref", attribute.Name);
@ -84,6 +84,13 @@ namespace Microsoft.CodeAnalysis.Razor
Assert.False(attribute.IsStringProperty);
Assert.False(attribute.IsBooleanProperty);
Assert.False(attribute.IsEnum);
var parameter = Assert.Single(attribute.BoundAttributeParameters);
Assert.Empty(parameter.Diagnostics);
Assert.Equal(":suppressField", parameter.DisplayName);
Assert.Equal("Suppresses the generation of a field by '@ref'. Specify '@ref:suppressField' to define your own property or field.", parameter.Documentation);
Assert.True(parameter.IsBooleanProperty);
Assert.Equal("suppressField", parameter.Name);
}
}
}