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/test/IntegrationTests/ComponentDeclarationIntegrationTest.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDeclarationIntegrationTest.cs index 25ec85093b..b3e35fd973 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDeclarationIntegrationTest.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentDeclarationIntegrationTest.cs @@ -70,6 +70,21 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests Assert.Same(typeof(StringBuilder), property.PropertyType); } + [Fact] + public void DeclarationConfiguration_IncludesRef() + { + // Arrange & Act + var component = CompileToComponent(@" +@using System.Text +
+"); + + // Assert + var field = component.GetType().GetField("myDiv", BindingFlags.NonPublic | BindingFlags.Instance); + Assert.NotNull(field); + Assert.Same(typeof(ElementRef), field.FieldType); + } + [Fact] public void DeclarationConfiguration_IncludesInherits() {