dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.

Home Page:https://asp.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RenderFragment becomes visible after hot reload

jburman opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Runtime: 6.0.5
SDK: 6.0.300

Scenario:

I have a WinForms app with Blazor Web View, running from command line with dotnet watch run.

In the MainLayout I have a snippet like below:

<If Value="AppState.AdminMode">
    <True>
        <a href="#" class="btn btn-outline-dark btn-lg float-right mr-2" @onclick="HandleExitAdminClicked">Exit Admin</a>
    </True>
</If>

The If.razor component is as below:

@if (Value)
{
    @True
}
else if(False is not null)
{
    @False
}

@code 
{
    [Parameter] public bool Value { get; set; }

    [Parameter] public RenderFragment True { get; set; } = default!;
    
    [Parameter] public RenderFragment? False { get; set; }
}

When app initially loads, AppState.AdminMode has a value of false, and the Exit Admin button is hidden. If I change some text in the MainLayout and hot reload runs, AppState.AdminMode is still false, but the Exit Admin button becomes visible.
Is there an explanation for this? The same thing happens across the app for all If component usages (this component is defined in a separate Razor Component library if that matters.)

Note: Replacing the If component with a if() statement causes the button to be correctly hidden.

Here is my .csproj settings...


<Project Sdk="Microsoft.NET.Sdk.Razor">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net6.0-windows</TargetFramework>
    <Nullable>enable</Nullable>
    <UseWindowsForms>true</UseWindowsForms>
    <ImplicitUsings>enable</ImplicitUsings>
    <Configurations>Debug;Release</Configurations>
    <ApplicationIcon>Icon.ico</ApplicationIcon>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components.WebView.WindowsForms" Version="6.0.312" />
    <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.1" />
  </ItemGroup>

  <ItemGroup>
...removed...
  </ItemGroup>

  <ItemGroup>
    <Content Update="wwwroot\**">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
  
</Project>

Expected Behavior

The RenderFragment should not be rendered.

Steps To Reproduce

Create a WinForms project with a Blazor WebView, add the component (defined above) somewhere, and run with dotnet watch run. Trigger a hot reload.

Exceptions (if any)

No response

.NET Version

6.0.5

Anything else?

No response

Thanks for contacting us.
We're moving this issue to the .NET 7 Planning milestone for future evaluation / consideration. Because it's not immediately obvious that this is a bug in our framework, we would like to keep this around to collect more feedback, which can later help us determine the impact of it. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

Hi. Thanks for contacting us.
We're closing this issue as there was not much community interest in this ask for quite a while now.
You can learn more about our triage process and how we handle issues by reading our Triage Process writeup.