diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx
index 610c13afcf..291c4d8723 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/ComponentResources.resx
@@ -196,10 +196,7 @@
route template
- Generates the specified field, and populates it during rendering with a reference to the element or component.
-
-
- Suppresses the generation of a field by '@ref'. Specify '@ref:suppressField' to define your own property or field.
+ Populates the specified field or property with a reference to the element or component.
Merges a collection of attributes into the current element or component.
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs
index 0b37c16233..05ef511fee 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentDiagnosticFactory.cs
@@ -396,35 +396,9 @@ 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);
- }
-
public static readonly RazorDiagnosticDescriptor ComponentNamesCannotStartWithLowerCase =
new RazorDiagnosticDescriptor(
- $"{DiagnosticPrefix}10013",
+ $"{DiagnosticPrefix}10011",
() => "Component '{0}' starts with a lowercase character. Component names cannot start with a lowercase character.",
RazorDiagnosticSeverity.Error);
@@ -438,7 +412,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components
public static readonly RazorDiagnosticDescriptor UnexpectedMarkupElement =
new RazorDiagnosticDescriptor(
- $"{DiagnosticPrefix}10014",
+ $"{DiagnosticPrefix}10012",
() => "Found markup element with unexpected name '{0}'. If this is intended to be a component, add a @using directive for its namespace.",
RazorDiagnosticSeverity.Warning);
@@ -452,7 +426,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components
public static readonly RazorDiagnosticDescriptor InconsistentStartAndEndTagName =
new RazorDiagnosticDescriptor(
- $"{DiagnosticPrefix}10015",
+ $"{DiagnosticPrefix}10013",
() => "The start tag name '{0}' does not match the end tag name '{1}'. Components must have matching start and end tag names (case-sensitive).",
RazorDiagnosticSeverity.Error);
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentReferenceCaptureLoweringPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentReferenceCaptureLoweringPass.cs
index 6a24a46f80..b4d776aacf 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentReferenceCaptureLoweringPass.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentReferenceCaptureLoweringPass.cs
@@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-using System;
-using System.Linq;
using Microsoft.AspNetCore.Razor.Language.Intermediate;
namespace Microsoft.AspNetCore.Razor.Language.Components
@@ -35,109 +33,34 @@ namespace Microsoft.AspNetCore.Razor.Language.Components
if (node.TagHelper.IsRefTagHelper())
{
- // 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));
- }
+ reference.Replace(RewriteUsage(@class, reference.Parent, node));
}
}
}
- private ReferenceCaptureIntermediateNode RewriteUsage(IntermediateNode parent, IntermediateToken identifier)
+ private IntermediateNode RewriteUsage(ClassDeclarationIntermediateNode classNode, IntermediateNode parent, TagHelperDirectiveAttributeIntermediateNode node)
{
+ // If we can't get a nonempty attribute name, do nothing because there will
+ // already be a diagnostic for empty values
+ var identifierToken = DetermineIdentifierToken(node);
+ if (identifierToken == null)
+ {
+ return node;
+ }
+
// Determine whether this is an element capture or a component capture, and
// if applicable the type name that will appear in the resulting capture code
var componentTagHelper = (parent as ComponentIntermediateNode)?.Component;
if (componentTagHelper != null)
{
- return new ReferenceCaptureIntermediateNode(identifier, componentTagHelper.GetTypeName());
+ return new ReferenceCaptureIntermediateNode(identifierToken, componentTagHelper.GetTypeName());
}
else
{
- return new ReferenceCaptureIntermediateNode(identifier);
+ return new ReferenceCaptureIntermediateNode(identifierToken);
}
}
- private bool ShouldGenerateField(IntermediateNode parent)
- {
- var parameters = parent.FindDescendantNodes();
- 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;
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Extensions/EliminateMethodBodyPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Extensions/EliminateMethodBodyPass.cs
index 96d336ca72..c14950aae5 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Extensions/EliminateMethodBodyPass.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Extensions/EliminateMethodBodyPass.cs
@@ -8,8 +8,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Extensions
{
internal sealed class EliminateMethodBodyPass : IntermediateNodePassBase, IRazorOptimizationPass
{
- // Run early in the optimization phase
- public override int Order => int.MinValue;
+ // Run late in the optimization phase
+ public override int Order => int.MaxValue;
protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode)
{
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Intermediate/ReferenceCaptureIntermediateNode.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Intermediate/ReferenceCaptureIntermediateNode.cs
index 48e6bc7d03..eb6f2d9c47 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Intermediate/ReferenceCaptureIntermediateNode.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Intermediate/ReferenceCaptureIntermediateNode.cs
@@ -2,6 +2,7 @@
// 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
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentChildContentIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentChildContentIntegrationTest.cs
index 13d5fa9e82..624de396b5 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentChildContentIntegrationTest.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentChildContentIntegrationTest.cs
@@ -163,7 +163,7 @@ Some Content
// Assert
Assert.Collection(
generated.Diagnostics,
- d => Assert.Equal("RZ10014", d.Id),
+ d => Assert.Equal("RZ10012", d.Id),
d => Assert.Equal("RZ9996", d.Id));
}
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs
index df812b8432..895e84e9c5 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs
@@ -3305,39 +3305,10 @@ namespace Test
// Act
var generated = CompileToCSharp(@"
+
@code {
- 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 : ComponentBase
- {
- [Parameter] public TItem Item { get; set; }
- }
-}
-"));
-
- // Act
- var generated = CompileToCSharp(@"
-
-@code {
- MyComponent _my;
- void DoStuff() { GC.KeepAlive(_my); }
+ private MyComponent _my;
+ public void Foo() { System.GC.KeepAlive(_my); }
}
");
@@ -3367,38 +3338,6 @@ namespace Test
var generated = CompileToCSharp(@"
-@code {
- private MyComponent _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 : ComponentBase
- {
- [Parameter] public TItem Item { get; set; }
- }
-}
-"));
-
- // Act
- var generated = CompileToCSharp(@"
-
-
@code {
private MyComponent _my;
public void Foo() { System.GC.KeepAlive(_my); }
@@ -3900,7 +3839,13 @@ namespace Test
{
// Arrange/Act
var generated = CompileToCSharp(@"
-Hello");
+Hello
+
+@code {
+ private Microsoft.AspNetCore.Components.ElementReference myElem;
+ public void Foo() { System.GC.KeepAlive(myElem); }
+}
+");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
@@ -3916,7 +3861,10 @@ namespace Test
@code {
+ private ElementReference _element;
+
[Parameter] public int Min { get; set; }
+ public void Foo() { System.GC.KeepAlive(_element); }
}
");
@@ -3926,35 +3874,6 @@ namespace Test
CompileToAssembly(generated);
}
- [Fact]
- public void Element_WithRef_SuppressField()
- {
- // Arrange/Act
- var generated = CompileToCSharp(@"
-Hello
-@code {
- ElementReference 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(@"
-Hello", throwOnFailure: false);
-
- // Assert
- var diagnostic = Assert.Single(generated.Diagnostics);
- Assert.Same(diagnostic.Id, ComponentDiagnosticFactory.RefSuppressFieldNotMinimized.Id);
- }
-
[Fact]
public void Component_WithRef()
{
@@ -3972,7 +3891,13 @@ namespace Test
// Arrange/Act
var generated = CompileToCSharp(@"
-");
+
+
+@code {
+ private Test.MyComponent myInstance;
+ public void Foo() { System.GC.KeepAlive(myInstance); }
+}
+");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
@@ -4000,36 +3925,12 @@ namespace Test
Some further content
-");
- // Assert
- AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
- AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
- 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(@"
-
@code {
- MyComponent myInstance;
- void DoStuff() { GC.KeepAlive(myInstance); }
-}");
+ private Test.MyComponent myInstance;
+ public void Foo() { System.GC.KeepAlive(myInstance); }
+}
+");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDiagnosticRazorIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDiagnosticRazorIntegrationTest.cs
index dc0b1b4cf9..863e2a0d16 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDiagnosticRazorIntegrationTest.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDiagnosticRazorIntegrationTest.cs
@@ -140,7 +140,7 @@ namespace Test
// Assert
var diagnostic = Assert.Single(generated.Diagnostics);
- Assert.Equal("RZ10013", diagnostic.Id);
+ Assert.Equal("RZ10011", diagnostic.Id);
Assert.Equal(
"Component 'lowerCase' starts with a lowercase character. Component names cannot start with a lowercase character.",
diagnostic.GetMessage());
@@ -159,7 +159,7 @@ namespace Test
// Assert
var diagnostic = Assert.Single(generated.Diagnostics);
- Assert.Equal("RZ10014", diagnostic.Id);
+ Assert.Equal("RZ10012", diagnostic.Id);
Assert.Equal(RazorDiagnosticSeverity.Warning, diagnostic.Severity);
Assert.Equal(
"Found markup element with unexpected name 'PossibleComponent'. If this is intended to be a component, add a @using directive for its namespace.",
@@ -196,7 +196,7 @@ namespace Test
// Assert
var diagnostic = Assert.Single(generated.Diagnostics);
- Assert.Equal("RZ10015", diagnostic.Id);
+ Assert.Equal("RZ10013", diagnostic.Id);
Assert.Equal(
"The start tag name 'MyComponent' does not match the end tag name 'mycomponent'. Components must have matching start and end tag names (case-sensitive).",
diagnostic.GetMessage());
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_IgnoresStaticAndAliasUsings/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_IgnoresStaticAndAliasUsings/TestComponent.diagnostics.txt
index 0dcd6ea2b9..e18bbb4149 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_IgnoresStaticAndAliasUsings/TestComponent.diagnostics.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_IgnoresStaticAndAliasUsings/TestComponent.diagnostics.txt
@@ -1 +1 @@
-x:\dir\subdir\Test\TestComponent.cshtml(4,1): Warning RZ10014: Found markup element with unexpected name 'SomeComponent'. If this is intended to be a component, add a @using directive for its namespace.
+x:\dir\subdir\Test\TestComponent.cshtml(4,1): Warning RZ10012: Found markup element with unexpected name 'SomeComponent'. If this is intended to be a component, add a @using directive for its namespace.
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.codegen.cs
index ee79e51bc7..9fe44c8dcf 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.codegen.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.codegen.cs
@@ -10,11 +10,6 @@ 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__() {
}
@@ -46,6 +41,15 @@ __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
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.ir.txt
index 25a4ad4d99..2e4013600f 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.ir.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.ir.txt
@@ -6,7 +6,6 @@ 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
@@ -23,3 +22,9 @@ 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
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.mappings.txt
index 58fd008a0c..af797a4e3d 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.mappings.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef/TestComponent.mappings.txt
@@ -1,5 +1,16 @@
Source Location: (40:0,40 [10] x:\dir\subdir\Test\TestComponent.cshtml)
|myInstance|
-Generated Location: (1283:34,40 [10] )
+Generated Location: (1085:29,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: (1450:45,7 [104] )
+|
+ private Test.MyComponent myInstance;
+ public void Foo() { System.GC.KeepAlive(myInstance); }
+|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_SuppressField/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_SuppressField/TestComponent.codegen.cs
deleted file mode 100644
index ba331d501d..0000000000
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_SuppressField/TestComponent.codegen.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-#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.Rendering.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
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_SuppressField/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_SuppressField/TestComponent.ir.txt
deleted file mode 100644
index 25bc61b8d8..0000000000
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_SuppressField/TestComponent.ir.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-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
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_SuppressField/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_SuppressField/TestComponent.mappings.txt
deleted file mode 100644
index 9b23b9d6be..0000000000
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_SuppressField/TestComponent.mappings.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-Source Location: (19:0,19 [10] x:\dir\subdir\Test\TestComponent.cshtml)
-|myInstance|
-Generated Location: (1018: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: (1383:43,7 [81] )
-|
- MyComponent myInstance;
- void DoStuff() { GC.KeepAlive(myInstance); }
-|
-
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.codegen.cs
index 94157bb880..aa03027573 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.codegen.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.codegen.cs
@@ -10,11 +10,6 @@ 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__() {
}
@@ -45,6 +40,15 @@ __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
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.ir.txt
index 514feb7edb..a2aae2c90d 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.ir.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.ir.txt
@@ -6,7 +6,6 @@ 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
@@ -28,5 +27,9 @@ 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 [2] x:\dir\subdir\Test\TestComponent.cshtml)
- IntermediateToken - (97:2,14 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ 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
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt
index e79503fbd8..eceb35d3f6 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt
@@ -1,5 +1,16 @@
Source Location: (19:0,19 [10] x:\dir\subdir\Test\TestComponent.cshtml)
|myInstance|
-Generated Location: (1239:33,19 [10] )
+Generated Location: (1041:28,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: (1406:44,7 [104] )
+|
+ private Test.MyComponent myInstance;
+ public void Foo() { System.GC.KeepAlive(myInstance); }
+|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.codegen.cs
index 5d2a1913e2..51ee950d02 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.codegen.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.codegen.cs
@@ -10,11 +10,6 @@ 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.ElementReference myElem;
- #pragma warning restore 0169
- #pragma warning restore 0414
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
}
@@ -34,6 +29,15 @@ namespace Test
#nullable disable
}
#pragma warning restore 1998
+#nullable restore
+#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
+
+ private Microsoft.AspNetCore.Components.ElementReference myElem;
+ public void Foo() { System.GC.KeepAlive(myElem); }
+
+#line default
+#line hidden
+#nullable disable
}
}
#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.ir.txt
index c321049510..6da670c14d 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.ir.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.ir.txt
@@ -6,7 +6,6 @@ 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.ElementReference - myElem
DesignTimeDirective -
CSharpCode -
IntermediateToken - - CSharp - #pragma warning disable 0414
@@ -25,3 +24,9 @@ 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 - (220:5,1 [2] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (220:5,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ CSharpCode - (91:2,7 [128] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (91:2,7 [128] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private Microsoft.AspNetCore.Components.ElementReference myElem;\n public void Foo() { System.GC.KeepAlive(myElem); }\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.mappings.txt
index a5390e3ed9..128fa2be26 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.mappings.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef/TestComponent.mappings.txt
@@ -1,5 +1,16 @@
Source Location: (37:0,37 [6] x:\dir\subdir\Test\TestComponent.cshtml)
|myElem|
-Generated Location: (1115:29,37 [6] )
+Generated Location: (881:24,37 [6] )
|myElem|
+Source Location: (91:2,7 [128] x:\dir\subdir\Test\TestComponent.cshtml)
+|
+ private Microsoft.AspNetCore.Components.ElementReference myElem;
+ public void Foo() { System.GC.KeepAlive(myElem); }
+|
+Generated Location: (1126:33,7 [128] )
+|
+ private Microsoft.AspNetCore.Components.ElementReference myElem;
+ public void Foo() { System.GC.KeepAlive(myElem); }
+|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.codegen.cs
index 51761425a0..5f22a7aec4 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.codegen.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.codegen.cs
@@ -10,11 +10,6 @@ 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.ElementReference _element;
- #pragma warning restore 0169
- #pragma warning restore 0414
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
}
@@ -46,7 +41,10 @@ namespace Test
#nullable restore
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
+ private ElementReference _element;
+
[Parameter] public int Min { get; set; }
+ public void Foo() { System.GC.KeepAlive(_element); }
#line default
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.ir.txt
index 647bf2d50e..5acd58a514 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.ir.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.ir.txt
@@ -6,7 +6,6 @@ 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.ElementReference - _element
DesignTimeDirective -
CSharpCode -
IntermediateToken - - CSharp - #pragma warning disable 0414
@@ -25,7 +24,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 - (129:4,5 [2] x:\dir\subdir\Test\TestComponent.cshtml)
- IntermediateToken - (129:4,5 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
- CSharpCode - (72:2,7 [56] x:\dir\subdir\Test\TestComponent.cshtml)
- IntermediateToken - (72:2,7 [56] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n [Parameter] public int Min { get; set; }\n
+ HtmlContent - (237:7,5 [2] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (237:7,5 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ CSharpCode - (72:2,7 [164] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (72:2,7 [164] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private ElementReference _element;\n\n [Parameter] public int Min { get; set; }\n public void Foo() { System.GC.KeepAlive(_element); }\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.mappings.txt
index 809182470a..bf4a929596 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.mappings.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.mappings.txt
@@ -1,19 +1,25 @@
Source Location: (37:0,37 [3] x:\dir\subdir\Test\TestComponent.cshtml)
|Min|
-Generated Location: (1137:30,37 [3] )
+Generated Location: (901:25,37 [3] )
|Min|
Source Location: (49:0,49 [8] x:\dir\subdir\Test\TestComponent.cshtml)
|_element|
-Generated Location: (1326:38,49 [8] )
+Generated Location: (1090:33,49 [8] )
|_element|
-Source Location: (72:2,7 [56] x:\dir\subdir\Test\TestComponent.cshtml)
+Source Location: (72:2,7 [164] x:\dir\subdir\Test\TestComponent.cshtml)
|
+ private ElementReference _element;
+
[Parameter] public int Min { get; set; }
+ public void Foo() { System.GC.KeepAlive(_element); }
|
-Generated Location: (1573:47,7 [56] )
+Generated Location: (1337:42,7 [164] )
|
+ private ElementReference _element;
+
[Parameter] public int Min { get; set; }
+ public void Foo() { System.GC.KeepAlive(_element); }
|
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_SuppressField/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_SuppressField/TestComponent.codegen.cs
deleted file mode 100644
index e806b81275..0000000000
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_SuppressField/TestComponent.codegen.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-#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.Rendering.RenderTreeBuilder __builder)
- {
-#nullable restore
-#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
- myElem = default(Microsoft.AspNetCore.Components.ElementReference);
-
-#line default
-#line hidden
-#nullable disable
- }
- #pragma warning restore 1998
-#nullable restore
-#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
-
- ElementReference myElem;
- void DoStuff() { GC.KeepAlive(myElem); }
-
-#line default
-#line hidden
-#nullable disable
- }
-}
-#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_SuppressField/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_SuppressField/TestComponent.ir.txt
deleted file mode 100644
index e505e82004..0000000000
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_SuppressField/TestComponent.ir.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-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 [78] x:\dir\subdir\Test\TestComponent.cshtml)
- IntermediateToken - (60:1,7 [78] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n ElementReference myElem;\n void DoStuff() { GC.KeepAlive(myElem); }\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_SuppressField/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_SuppressField/TestComponent.mappings.txt
deleted file mode 100644
index c3556e4657..0000000000
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_SuppressField/TestComponent.mappings.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-Source Location: (12:0,12 [6] x:\dir\subdir\Test\TestComponent.cshtml)
-|myElem|
-Generated Location: (856:24,12 [6] )
-|myElem|
-
-Source Location: (60:1,7 [78] x:\dir\subdir\Test\TestComponent.cshtml)
-|
- ElementReference myElem;
- void DoStuff() { GC.KeepAlive(myElem); }
-|
-Generated Location: (1101:33,7 [78] )
-|
- ElementReference myElem;
- void DoStuff() { GC.KeepAlive(myElem); }
-|
-
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.codegen.cs
deleted file mode 100644
index f98dd68089..0000000000
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.codegen.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-#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
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.diagnostics.txt
deleted file mode 100644
index bd82282e59..0000000000
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.diagnostics.txt
+++ /dev/null
@@ -1 +0,0 @@
-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.
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.ir.txt
deleted file mode 100644
index 69ddf6a8cd..0000000000
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.ir.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-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
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.mappings.txt
deleted file mode 100644
index b77841ef4b..0000000000
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.mappings.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-Source Location: (12:0,12 [6] x:\dir\subdir\Test\TestComponent.cshtml)
-|myElem|
-Generated Location: (1083:29,12 [6] )
-|myElem|
-
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_SuppressField/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.codegen.cs
similarity index 93%
rename from src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_SuppressField/TestComponent.codegen.cs
rename to src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.codegen.cs
index c7d9b20432..5b6d83a8c0 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_SuppressField/TestComponent.codegen.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.codegen.cs
@@ -58,10 +58,10 @@ __o = typeof(MyComponent<>);
}
#pragma warning restore 1998
#nullable restore
-#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
+#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
- MyComponent _my;
- void DoStuff() { GC.KeepAlive(_my); }
+ private MyComponent _my;
+ public void Foo() { System.GC.KeepAlive(_my); }
#line default
#line hidden
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_SuppressField/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.ir.txt
similarity index 71%
rename from src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_SuppressField/TestComponent.ir.txt
rename to src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.ir.txt
index f5a1218aee..f634b69431 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_SuppressField/TestComponent.ir.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.ir.txt
@@ -14,15 +14,15 @@ Document -
CSharpCode -
IntermediateToken - - CSharp - #pragma warning restore 0414
MethodDeclaration - - protected override - void - BuildRenderTree
- Component - (0:0,0 [64] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
+ Component - (0:0,0 [45] 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 - (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 _my;\n void DoStuff() { GC.KeepAlive(_my); }\n
+ 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 _my;\n public void Foo() { System.GC.KeepAlive(_my); }\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_SuppressField/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.mappings.txt
similarity index 57%
rename from src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_SuppressField/TestComponent.mappings.txt
rename to src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.mappings.txt
index d0bf71a61d..b7ec0ca120 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_SuppressField/TestComponent.mappings.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.mappings.txt
@@ -13,14 +13,14 @@ Source Location: (38:0,38 [3] x:\dir\subdir\Test\TestComponent.cshtml)
Generated Location: (1491:45,38 [3] )
|_my|
-Source Location: (73:1,7 [72] x:\dir\subdir\Test\TestComponent.cshtml)
+Source Location: (56:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml)
|
- MyComponent _my;
- void DoStuff() { GC.KeepAlive(_my); }
+ private MyComponent _my;
+ public void Foo() { System.GC.KeepAlive(_my); }
|
-Generated Location: (1856:61,7 [72] )
+Generated Location: (1856:61,7 [90] )
|
- MyComponent _my;
- void DoStuff() { GC.KeepAlive(_my); }
+ private MyComponent _my;
+ public void Foo() { System.GC.KeepAlive(_my); }
|
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_SuppressField/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_CreatesDiagnostic/TestComponent.codegen.cs
similarity index 100%
rename from src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_SuppressField/TestComponent.codegen.cs
rename to src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_CreatesDiagnostic/TestComponent.codegen.cs
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_SuppressField/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_CreatesDiagnostic/TestComponent.ir.txt
similarity index 79%
rename from src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_SuppressField/TestComponent.ir.txt
rename to src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_CreatesDiagnostic/TestComponent.ir.txt
index 3f12dd56b1..2d876f125f 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_SuppressField/TestComponent.ir.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_CreatesDiagnostic/TestComponent.ir.txt
@@ -14,16 +14,16 @@ Document -
CSharpCode -
IntermediateToken - - CSharp - #pragma warning restore 0414
MethodDeclaration - - protected override - void - BuildRenderTree
- Component - (0:0,0 [54] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent
+ 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
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 - (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 _my;\n public void Foo() { System.GC.KeepAlive(_my); }\n
+ 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 _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
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_SuppressField/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_CreatesDiagnostic/TestComponent.mappings.txt
similarity index 87%
rename from src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_SuppressField/TestComponent.mappings.txt
rename to src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_CreatesDiagnostic/TestComponent.mappings.txt
index 868efd46b6..317c9822e4 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_SuppressField/TestComponent.mappings.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_CreatesDiagnostic/TestComponent.mappings.txt
@@ -8,7 +8,7 @@ Source Location: (28:0,28 [3] x:\dir\subdir\Test\TestComponent.cshtml)
Generated Location: (1143:33,28 [3] )
|_my|
-Source Location: (65:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml)
+Source Location: (46:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml)
|
private MyComponent _my;
public void Foo() { System.GC.KeepAlive(_my); }
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_IgnoresStaticAndAliasUsings/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_IgnoresStaticAndAliasUsings/TestComponent.diagnostics.txt
index 0dcd6ea2b9..e18bbb4149 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_IgnoresStaticAndAliasUsings/TestComponent.diagnostics.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_IgnoresStaticAndAliasUsings/TestComponent.diagnostics.txt
@@ -1 +1 @@
-x:\dir\subdir\Test\TestComponent.cshtml(4,1): Warning RZ10014: Found markup element with unexpected name 'SomeComponent'. If this is intended to be a component, add a @using directive for its namespace.
+x:\dir\subdir\Test\TestComponent.cshtml(4,1): Warning RZ10012: Found markup element with unexpected name 'SomeComponent'. If this is intended to be a component, add a @using directive for its namespace.
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef/TestComponent.codegen.cs
index 45f0b5c057..ba86a76a59 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef/TestComponent.codegen.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef/TestComponent.codegen.cs
@@ -10,11 +10,6 @@ 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.Rendering.RenderTreeBuilder __builder)
{
@@ -34,6 +29,15 @@ 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
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef/TestComponent.ir.txt
index be89b1cae3..c724647179 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef/TestComponent.ir.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef/TestComponent.ir.txt
@@ -6,7 +6,6 @@ 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
@@ -16,3 +15,5 @@ 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
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef/TestComponent.mappings.txt
index 3ad55818a2..0ca7d8ee94 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef/TestComponent.mappings.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef/TestComponent.mappings.txt
@@ -1,5 +1,16 @@
Source Location: (40:0,40 [10] x:\dir\subdir\Test\TestComponent.cshtml)
|myInstance|
-Generated Location: (1071:26,40 [10] )
+Generated Location: (873:21,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: (1162:33,7 [104] )
+|
+ private Test.MyComponent myInstance;
+ public void Foo() { System.GC.KeepAlive(myInstance); }
+|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_SuppressField/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_SuppressField/TestComponent.codegen.cs
deleted file mode 100644
index c4fc11129d..0000000000
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_SuppressField/TestComponent.codegen.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-#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.Rendering.RenderTreeBuilder __builder)
- {
- __builder.OpenComponent(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
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_SuppressField/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_SuppressField/TestComponent.ir.txt
deleted file mode 100644
index a39ce1d3c4..0000000000
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_SuppressField/TestComponent.ir.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-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
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_SuppressField/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_SuppressField/TestComponent.mappings.txt
deleted file mode 100644
index dad9e5fd6d..0000000000
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_SuppressField/TestComponent.mappings.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-Source Location: (19:0,19 [10] x:\dir\subdir\Test\TestComponent.cshtml)
-|myInstance|
-Generated Location: (724: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: (1013:31,7 [81] )
-|
- MyComponent myInstance;
- void DoStuff() { GC.KeepAlive(myInstance); }
-|
-
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.codegen.cs
index 251726dde2..500298b6c9 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.codegen.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.codegen.cs
@@ -10,11 +10,6 @@ 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.Rendering.RenderTreeBuilder __builder)
{
@@ -38,6 +33,15 @@ 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
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.ir.txt
index e99793984f..1bc1814490 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.ir.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.ir.txt
@@ -6,7 +6,6 @@ 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
@@ -17,3 +16,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
+ 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
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt
index 6a8210af48..1f290c1c54 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt
@@ -1,5 +1,16 @@
Source Location: (19:0,19 [10] x:\dir\subdir\Test\TestComponent.cshtml)
|myInstance|
-Generated Location: (1282:32,19 [10] )
+Generated Location: (1084:27,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: (1373:39,7 [104] )
+|
+ private Test.MyComponent myInstance;
+ public void Foo() { System.GC.KeepAlive(myInstance); }
+|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef/TestComponent.codegen.cs
index 4ab0319ccd..bccd61fb44 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef/TestComponent.codegen.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef/TestComponent.codegen.cs
@@ -10,11 +10,6 @@ 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.ElementReference myElem;
- #pragma warning restore 0169
- #pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
{
@@ -35,6 +30,15 @@ namespace Test
__builder.CloseElement();
}
#pragma warning restore 1998
+#nullable restore
+#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
+
+ private Microsoft.AspNetCore.Components.ElementReference myElem;
+ public void Foo() { System.GC.KeepAlive(myElem); }
+
+#line default
+#line hidden
+#nullable disable
}
}
#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef/TestComponent.ir.txt
index c51872c53f..b9ffc7754d 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef/TestComponent.ir.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef/TestComponent.ir.txt
@@ -6,7 +6,6 @@ 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.ElementReference - 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)
@@ -18,3 +17,5 @@ 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 [128] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (91:2,7 [128] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private Microsoft.AspNetCore.Components.ElementReference myElem;\n public void Foo() { System.GC.KeepAlive(myElem); }\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef/TestComponent.mappings.txt
index ac62465376..33a1ffc706 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef/TestComponent.mappings.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef/TestComponent.mappings.txt
@@ -1,5 +1,16 @@
Source Location: (37:0,37 [6] x:\dir\subdir\Test\TestComponent.cshtml)
|myElem|
-Generated Location: (1098:26,37 [6] )
+Generated Location: (864:21,37 [6] )
|myElem|
+Source Location: (91:2,7 [128] x:\dir\subdir\Test\TestComponent.cshtml)
+|
+ private Microsoft.AspNetCore.Components.ElementReference myElem;
+ public void Foo() { System.GC.KeepAlive(myElem); }
+|
+Generated Location: (1176:34,7 [128] )
+|
+ private Microsoft.AspNetCore.Components.ElementReference myElem;
+ public void Foo() { System.GC.KeepAlive(myElem); }
+|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.codegen.cs
index 7cec406182..f425681378 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.codegen.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.codegen.cs
@@ -10,11 +10,6 @@ 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.ElementReference _element;
- #pragma warning restore 0169
- #pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
{
@@ -45,7 +40,10 @@ namespace Test
#nullable restore
#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
+ private ElementReference _element;
+
[Parameter] public int Min { get; set; }
+ public void Foo() { System.GC.KeepAlive(_element); }
#line default
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.ir.txt
index c0fd524c30..62d17f05fd 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.ir.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.ir.txt
@@ -6,7 +6,6 @@ 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.ElementReference - _element
MethodDeclaration - - protected override - void - BuildRenderTree
MarkupElement - (0:0,0 [61] x:\dir\subdir\Test\TestComponent.cshtml) - input
HtmlAttribute - - type=" - "
@@ -16,5 +15,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 [56] x:\dir\subdir\Test\TestComponent.cshtml)
- IntermediateToken - (72:2,7 [56] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n [Parameter] public int Min { get; set; }\n
+ CSharpCode - (72:2,7 [164] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (72:2,7 [164] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n private ElementReference _element;\n\n [Parameter] public int Min { get; set; }\n public void Foo() { System.GC.KeepAlive(_element); }\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.mappings.txt
index 670974cf7b..f35554549b 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.mappings.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_AndOtherAttributes/TestComponent.mappings.txt
@@ -1,14 +1,20 @@
Source Location: (49:0,49 [8] x:\dir\subdir\Test\TestComponent.cshtml)
|_element|
-Generated Location: (1270:34,49 [8] )
+Generated Location: (1034:29,49 [8] )
|_element|
-Source Location: (72:2,7 [56] x:\dir\subdir\Test\TestComponent.cshtml)
+Source Location: (72:2,7 [164] x:\dir\subdir\Test\TestComponent.cshtml)
|
+ private ElementReference _element;
+
[Parameter] public int Min { get; set; }
+ public void Foo() { System.GC.KeepAlive(_element); }
|
-Generated Location: (1537:46,7 [56] )
+Generated Location: (1301:41,7 [164] )
|
+ private ElementReference _element;
+
[Parameter] public int Min { get; set; }
+ public void Foo() { System.GC.KeepAlive(_element); }
|
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_SuppressField/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_SuppressField/TestComponent.codegen.cs
deleted file mode 100644
index 0c480f76a7..0000000000
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_SuppressField/TestComponent.codegen.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-//
-#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.Rendering.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"
-
- ElementReference myElem;
- void DoStuff() { GC.KeepAlive(myElem); }
-
-#line default
-#line hidden
-#nullable disable
- }
-}
-#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_SuppressField/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_SuppressField/TestComponent.ir.txt
deleted file mode 100644
index 89666189e8..0000000000
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_SuppressField/TestComponent.ir.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-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 [78] x:\dir\subdir\Test\TestComponent.cshtml)
- IntermediateToken - (60:1,7 [78] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n ElementReference myElem;\n void DoStuff() { GC.KeepAlive(myElem); }\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_SuppressField/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_SuppressField/TestComponent.mappings.txt
deleted file mode 100644
index ac7adc105d..0000000000
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_SuppressField/TestComponent.mappings.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-Source Location: (12:0,12 [6] x:\dir\subdir\Test\TestComponent.cshtml)
-|myElem|
-Generated Location: (703:19,12 [6] )
-|myElem|
-
-Source Location: (60:1,7 [78] x:\dir\subdir\Test\TestComponent.cshtml)
-|
- ElementReference myElem;
- void DoStuff() { GC.KeepAlive(myElem); }
-|
-Generated Location: (1015:32,7 [78] )
-|
- ElementReference myElem;
- void DoStuff() { GC.KeepAlive(myElem); }
-|
-
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.codegen.cs
deleted file mode 100644
index 65d6d0d152..0000000000
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.codegen.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-#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
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.diagnostics.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.diagnostics.txt
deleted file mode 100644
index bd82282e59..0000000000
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.diagnostics.txt
+++ /dev/null
@@ -1 +0,0 @@
-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.
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.ir.txt
deleted file mode 100644
index b482efeff5..0000000000
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.ir.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-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
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.mappings.txt
deleted file mode 100644
index 7fbcfcd168..0000000000
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/Element_WithRef_SuppressFieldWithValue_ResultsInDiagnostic/TestComponent.mappings.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-Source Location: (12:0,12 [6] x:\dir\subdir\Test\TestComponent.cshtml)
-|myElem|
-Generated Location: (926:24,12 [6] )
-|myElem|
-
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.codegen.cs
index b33b86132c..2bae2266c8 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.codegen.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.codegen.cs
@@ -10,16 +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 _my;
- #pragma warning restore 0169
- #pragma warning restore 0414
#pragma warning disable 1998
- protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder)
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
{
- builder.OpenComponent>(0);
- builder.AddAttribute(1, "Item", Microsoft.AspNetCore.Components.RuntimeHelpers.TypeCheck(
+ __builder.OpenComponent>(0);
+ __builder.AddAttribute(1, "Item", Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck(
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
3
@@ -28,7 +23,7 @@ namespace Test
#line hidden
#nullable disable
));
- builder.AddComponentReferenceCapture(2, (__value) => {
+ __builder.AddComponentReferenceCapture(2, (__value) => {
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
_my = (Test.MyComponent)__value;
@@ -38,9 +33,18 @@ namespace Test
#nullable disable
}
);
- builder.CloseComponent();
+ __builder.CloseComponent();
}
#pragma warning restore 1998
+#nullable restore
+#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
+
+ private MyComponent _my;
+ public void Foo() { System.GC.KeepAlive(_my); }
+
+#line default
+#line hidden
+#nullable disable
}
}
#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.ir.txt
index 22c8243ee5..5dbefda847 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.ir.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.ir.txt
@@ -6,7 +6,6 @@ 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 - _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
@@ -14,3 +13,5 @@ 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 _my;\n public void Foo() { System.GC.KeepAlive(_my); }\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.mappings.txt
index a259494405..35cce98a12 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.mappings.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef/TestComponent.mappings.txt
@@ -1,5 +1,16 @@
Source Location: (38:0,38 [3] x:\dir\subdir\Test\TestComponent.cshtml)
|_my|
-Generated Location: (1218:33,38 [3] )
+Generated Location: (1044:28,38 [3] )
|_my|
+Source Location: (56:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml)
+|
+ private MyComponent _my;
+ public void Foo() { System.GC.KeepAlive(_my); }
+|
+Generated Location: (1331:40,7 [90] )
+|
+ private MyComponent _my;
+ public void Foo() { System.GC.KeepAlive(_my); }
+|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_SuppressField/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.codegen.cs
similarity index 90%
rename from src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_SuppressField/TestComponent.codegen.cs
rename to src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.codegen.cs
index 2551625019..2bae2266c8 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_SuppressField/TestComponent.codegen.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.codegen.cs
@@ -37,10 +37,10 @@ namespace Test
}
#pragma warning restore 1998
#nullable restore
-#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
+#line 3 "x:\dir\subdir\Test\TestComponent.cshtml"
- MyComponent _my;
- void DoStuff() { GC.KeepAlive(_my); }
+ private MyComponent _my;
+ public void Foo() { System.GC.KeepAlive(_my); }
#line default
#line hidden
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_SuppressField/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.ir.txt
similarity index 78%
rename from src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_SuppressField/TestComponent.ir.txt
rename to src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.ir.txt
index 3ed36f4932..5dbefda847 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_SuppressField/TestComponent.ir.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.ir.txt
@@ -7,11 +7,11 @@ Document -
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
+ Component - (0:0,0 [45] 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 _my;\n void DoStuff() { GC.KeepAlive(_my); }\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 _my;\n public void Foo() { System.GC.KeepAlive(_my); }\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.mappings.txt
new file mode 100644
index 0000000000..35cce98a12
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_CreatesDiagnostic/TestComponent.mappings.txt
@@ -0,0 +1,16 @@
+Source Location: (38:0,38 [3] x:\dir\subdir\Test\TestComponent.cshtml)
+|_my|
+Generated Location: (1044:28,38 [3] )
+|_my|
+
+Source Location: (56:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml)
+|
+ private MyComponent _my;
+ public void Foo() { System.GC.KeepAlive(_my); }
+|
+Generated Location: (1331:40,7 [90] )
+|
+ private MyComponent _my;
+ public void Foo() { System.GC.KeepAlive(_my); }
+|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_SuppressField/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_SuppressField/TestComponent.mappings.txt
deleted file mode 100644
index 8869512906..0000000000
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_SuppressField/TestComponent.mappings.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-Source Location: (38:0,38 [3] x:\dir\subdir\Test\TestComponent.cshtml)
-|_my|
-Generated Location: (1044:28,38 [3] )
-|_my|
-
-Source Location: (73:1,7 [72] x:\dir\subdir\Test\TestComponent.cshtml)
-|
- MyComponent _my;
- void DoStuff() { GC.KeepAlive(_my); }
-|
-Generated Location: (1331:40,7 [72] )
-|
- MyComponent _my;
- void DoStuff() { GC.KeepAlive(_my); }
-|
-
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.codegen.cs
index 523fdcd46c..bbcfa74722 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.codegen.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.codegen.cs
@@ -10,15 +10,10 @@ namespace Test
using Microsoft.AspNetCore.Components;
public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
{
- #pragma warning disable 0414
- #pragma warning disable 0169
- private Test.MyComponent _my;
- #pragma warning restore 0169
- #pragma warning restore 0414
#pragma warning disable 1998
- protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder)
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
{
- __Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(builder, 0, 1,
+ __Blazor.Test.TestComponent.TypeInference.CreateMyComponent_0(__builder, 0, 1,
#nullable restore
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
3
@@ -54,12 +49,12 @@ namespace __Blazor.Test.TestComponent
#line hidden
internal static class TypeInference
{
- public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, TItem __arg0, int __seq1, global::System.Action> __arg1)
+ public static void CreateMyComponent_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, TItem __arg0, int __seq1, global::System.Action> __arg1)
{
- builder.OpenComponent>(seq);
- builder.AddAttribute(__seq0, "Item", __arg0);
- builder.AddComponentReferenceCapture(__seq1, (__value) => { __arg1((global::Test.MyComponent)__value); });
- builder.CloseComponent();
+ __builder.OpenComponent>(seq);
+ __builder.AddAttribute(__seq0, "Item", __arg0);
+ __builder.AddComponentReferenceCapture(__seq1, (__value) => { __arg1((global::Test.MyComponent)__value); });
+ __builder.CloseComponent();
}
}
}
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.ir.txt
index ee14362fb9..cde256a50b 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.ir.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.ir.txt
@@ -6,7 +6,6 @@ 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 - _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
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.mappings.txt
index 7c936d6582..3c103a0ec3 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.mappings.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference/TestComponent.mappings.txt
@@ -1,6 +1,6 @@
Source Location: (28:0,28 [3] x:\dir\subdir\Test\TestComponent.cshtml)
|_my|
-Generated Location: (1067:31,28 [3] )
+Generated Location: (872:26,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 _my;
public void Foo() { System.GC.KeepAlive(_my); }
|
-Generated Location: (1290:42,7 [90] )
+Generated Location: (1095:37,7 [90] )
|
private MyComponent _my;
public void Foo() { System.GC.KeepAlive(_my); }
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_SuppressField/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_CreatesDiagnostic/TestComponent.codegen.cs
similarity index 100%
rename from src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_SuppressField/TestComponent.codegen.cs
rename to src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_CreatesDiagnostic/TestComponent.codegen.cs
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_SuppressField/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_CreatesDiagnostic/TestComponent.ir.txt
similarity index 87%
rename from src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_SuppressField/TestComponent.ir.txt
rename to src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_CreatesDiagnostic/TestComponent.ir.txt
index 30bbe933db..cde256a50b 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_SuppressField/TestComponent.ir.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_CreatesDiagnostic/TestComponent.ir.txt
@@ -7,12 +7,12 @@ Document -
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
+ 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
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 _my;\n public void Foo() { System.GC.KeepAlive(_my); }\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 _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
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_SuppressField/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_CreatesDiagnostic/TestComponent.mappings.txt
similarity index 84%
rename from src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_SuppressField/TestComponent.mappings.txt
rename to src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_CreatesDiagnostic/TestComponent.mappings.txt
index b85825c088..3c103a0ec3 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_SuppressField/TestComponent.mappings.txt
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/GenericComponent_WithComponentRef_TypeInference_CreatesDiagnostic/TestComponent.mappings.txt
@@ -3,7 +3,7 @@ Source Location: (28:0,28 [3] x:\dir\subdir\Test\TestComponent.cshtml)
Generated Location: (872:26,28 [3] )
|_my|
-Source Location: (65:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml)
+Source Location: (46:2,7 [90] x:\dir\subdir\Test\TestComponent.cshtml)
|
private MyComponent _my;
public void Foo() { System.GC.KeepAlive(_my); }
diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/RefTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/RefTagHelperDescriptorProvider.cs
index 3dc20da67f..1eafca4181 100644
--- a/src/Razor/Microsoft.CodeAnalysis.Razor/src/RefTagHelperDescriptorProvider.cs
+++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/RefTagHelperDescriptorProvider.cs
@@ -62,24 +62,16 @@ namespace Microsoft.CodeAnalysis.Razor
});
});
- builder.BindAttribute(@ref =>
+ builder.BindAttribute(attribute =>
{
- @ref.Documentation = ComponentResources.RefTagHelper_Documentation;
- @ref.Name = "@ref";
+ attribute.Documentation = ComponentResources.RefTagHelper_Documentation;
+ attribute.Name = "@ref";
// WTE has a bug 15.7p1 where a Tag Helper without a display-name that looks like
// a C# property will crash trying to create the tooltips.
- @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");
- });
+ attribute.SetPropertyName("Ref");
+ attribute.TypeName = typeof(object).FullName;
+ attribute.Metadata[ComponentMetadata.Common.DirectiveAttribute] = bool.TrueString;
});
return builder.Build();
diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/test/RefTagHelperDescriptorProviderTest.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/test/RefTagHelperDescriptorProviderTest.cs
index 5740418f77..140520153e 100644
--- a/src/Razor/Microsoft.CodeAnalysis.Razor/test/RefTagHelperDescriptorProviderTest.cs
+++ b/src/Razor/Microsoft.CodeAnalysis.Razor/test/RefTagHelperDescriptorProviderTest.cs
@@ -39,7 +39,7 @@ namespace Microsoft.CodeAnalysis.Razor
Assert.True(item.CaseSensitive);
Assert.Equal(
- "Generates the specified field, and populates it during rendering with a reference to the element or component.",
+ "Populates the specified field or property with a reference to the element or component.",
item.Documentation);
Assert.Equal("Microsoft.AspNetCore.Components", item.AssemblyName);
@@ -75,7 +75,7 @@ namespace Microsoft.CodeAnalysis.Razor
Assert.False(attribute.IsIndexerStringProperty);
Assert.Equal(
- "Generates the specified field, and populates it during rendering with a reference to the element or component.",
+ "Populates the specified field or property with a reference to the element or component.",
attribute.Documentation);
Assert.Equal("@ref", attribute.Name);
@@ -85,13 +85,6 @@ 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);
}
}
}
diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildWithComponentsIntegrationTest.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildWithComponentsIntegrationTest.cs
index 848587311d..ce867b6b8d 100644
--- a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildWithComponentsIntegrationTest.cs
+++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildWithComponentsIntegrationTest.cs
@@ -60,7 +60,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
// Verify component compilation succeeded
Assert.AssemblyContainsType(result, Path.Combine(OutputPath, "ComponentApp.dll"), "ComponentApp.Components.Pages.Counter");
- Assert.BuildWarning(result, "RZ10014");
+ Assert.BuildWarning(result, "RZ10012");
}
[Fact]