Closed mikewodarczyk closed 5 years ago
have u tried changing @ref:suppressfield to @ref:suppressField ?
Looks like @githubfanster might have the right answer. Could you try making that change to see if it resolves the crash?
@ajaybhargavb do you know why this might crash VS? That sounds problematic.
i was able to build your repo by making two changes:
in EditFields.razor, line 34: <EditForm @ref="EditFormElement" @ref:suppressField Model="@Distributor">
then in EditFieldsBase.cs line 26: from: protected ElementReference EditFormElement { get; set; } to protected EditForm EditFormElement { get; set; }
i thought your experience might have been related to this: https://github.com/aspnet/Announcements/issues/381
@githubfanster
Thanks! Making the changes @ref:suppressfield => @ref:suppressField and "protected ElementReference EditFormElement { get; set; }" to "protected EditForm EditFormElement { get; set; }" got the code to compile and stopped the visual studio crash. That gets me out of my issue and I can work with the latest patch release.
It still seems like the error message reported: "rzc generate exited with code 1." and the crash of visual studio when editing the razor file should be fixed. I think that there is work in the next pre-release 9 addressing this.
I will close this for now since it is a pre-release and I will re-test my broken code with the next pre-release and see if I need to reopen. Thanks!!
Verified this no longer crashes in preview9
Blazor code containing components using the @ref attribute cause an error in the method Microsoft.AspNetCore.Razor.Language.Components.ComponentReferenceCaptureLoweringPass.ExecuteCore which causes a compile time error to be produced and will crash Visual studio when the affected file is viewed in the editor.
This appears to be related to the issue https://github.com/aspnet/AspNetCore/issues/13115 however they were unable to create an example that fails and they closed the issue.
I have made a github repo with a small project that reproduces the issue. The repo is at: https://github.com/mikewodarczyk/BlazorVisualStudioBug
This started in Microsoft.AspNetCode.App version 3.0.0-preview8.19405.7 Microsoft.NETCode.App verion 3.0.0-preview8-28405-07
The code contains 1 added page "Create.razor" with backing code in "CreateBase.cs". This page includes a component "EditFields.razor" with backing code in "EditFieldsBase.cs". The Edit Fields razor page appears to be the source of the issue.
The base class contains the variable EditFormElement:
When you compile the code, you get the error:
and Output
Worse yet, if you try and edit the file BlazorApp1/Pages/EditFields.razor in Visual Studio and scroll down to line 34 which contains a @ref attribute. VS will hang and crash.
Expected behavior
There should either be a compile time error pointing to a line in my code with the error or there should be no compile time error at all.
Editing the file BlazorApp1/Pages/EditFields.razor in Visual Studio should not crash VS.
Additional context
dotnet --info
.NET Core SDK (reflecting any global.json): Version: 3.0.100-preview8-013656 Commit: 8bf06ffc8d
Runtime Environment: OS Name: Windows OS Version: 10.0.18362 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.0.100-preview8-013656\
Host (useful for support): Version: 3.0.0-preview8-28405-07 Commit: d01b2fb7bc
.NET Core SDKs installed: 1.0.0-preview1-002702 [C:\Program Files\dotnet\sdk] 1.0.0 [C:\Program Files\dotnet\sdk] 1.0.4 [C:\Program Files\dotnet\sdk] 1.1.0 [C:\Program Files\dotnet\sdk] 2.0.3 [C:\Program Files\dotnet\sdk] 2.1.104 [C:\Program Files\dotnet\sdk] 2.1.800 [C:\Program Files\dotnet\sdk] 2.2.101 [C:\Program Files\dotnet\sdk] 2.2.300-preview-010067 [C:\Program Files\dotnet\sdk] 3.0.100-preview6-012264 [C:\Program Files\dotnet\sdk] 3.0.100-preview8-013656 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0-preview6.19307.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0-preview8.19405.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 1.0.0-rc2-3002702 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 1.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 1.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0-preview6-27804-01 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.0-preview6-27804-01 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]