dotnet / razor

Compiler and tooling experience for Razor ASP.NET Core apps in Visual Studio, Visual Studio for Mac, and VS Code.
https://asp.net
MIT License
498 stars 191 forks source link

Blazor regression in 7.0.302 SDK #8718

Closed ScarletKuro closed 1 year ago

ScarletKuro commented 1 year ago

Is there an existing issue for this?

Describe the bug

Hello,

After updating the SDK to version 7.0.302, we encountered numerous errors in our MudBlazor project. One particular example is the ambiguous call issue shown in the screenshot below. It appears that the Razor parser has become more strict, and the unnecessary @ symbol may be causing the problem. However, I'm unsure how to resolve all the errors, such as The attribute names could not be inferred from bind attribute 'bind-IsVisible' or Multiple components use the tag 'MudSwitch'. Could you provide some insight into their meaning?

While I don't have a reproduction repository available, you can review the logs at the following link for further details: GitHub Logs

If you clone the MudBlazor repository and compile it with the 7.0.302 SDK version, you'll have a better understanding of the overall situation.

NB! creating global.json where you set previous SDK version does solve the problem, but this is not really a solution.

It would be greatly appreciated if you could provide any information or documentation regarding the changes and how to address them. Are there any workarounds available? I'm also curious why a breaking change was introduced in the .NET 7 SDK rather than do them in .NET 8.

Thank you for your assistance.

Exceptions (if any)

Error list example ``` Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(158,79): error CS1026: ) expected [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(158,79): error CS1003: Syntax error, ',' expected [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] ##[debug]Dropping file value '/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Microsoft.NET.Sdk.Razor.SourceGenerators/Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator/Components_DataGrid_MudDataGrid_razor.g.cs'. Path does not exist Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Microsoft.NET.Sdk.Razor.SourceGenerators/Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator/Components_DataGrid_MudDataGrid_razor.g.cs(970,32): error CS1002: ; expected [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] ##[debug]Dropping file value '/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Microsoft.NET.Sdk.Razor.SourceGenerators/Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator/Components_DataGrid_MudDataGrid_razor.g.cs'. Path does not exist Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Microsoft.NET.Sdk.Razor.SourceGenerators/Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator/Components_DataGrid_MudDataGrid_razor.g.cs(970,32): error CS1513: } expected [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(193,71): error CS1026: ) expected [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(193,71): error CS1003: Syntax error, ',' expected [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] ##[debug]Dropping file value '/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Microsoft.NET.Sdk.Razor.SourceGenerators/Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator/Components_DataGrid_MudDataGrid_razor.g.cs'. Path does not exist Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Microsoft.NET.Sdk.Razor.SourceGenerators/Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator/Components_DataGrid_MudDataGrid_razor.g.cs(1145,32): error CS1002: ; expected [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] ##[debug]Dropping file value '/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Microsoft.NET.Sdk.Razor.SourceGenerators/Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator/Components_DataGrid_MudDataGrid_razor.g.cs'. Path does not exist Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Microsoft.NET.Sdk.Razor.SourceGenerators/Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator/Components_DataGrid_MudDataGrid_razor.g.cs(1145,32): error CS1513: } expected [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(38,55): error CS1026: ) expected [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(38,55): error CS1003: Syntax error, ',' expected [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] ##[debug]Dropping file value '/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Microsoft.NET.Sdk.Razor.SourceGenerators/Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator/Components_DataGrid_MudDataGrid_razor.g.cs'. Path does not exist Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Microsoft.NET.Sdk.Razor.SourceGenerators/Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator/Components_DataGrid_MudDataGrid_razor.g.cs(1366,39): error CS1002: ; expected [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] ##[debug]Dropping file value '/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Microsoft.NET.Sdk.Razor.SourceGenerators/Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator/Components_DataGrid_MudDataGrid_razor.g.cs'. Path does not exist Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Microsoft.NET.Sdk.Razor.SourceGenerators/Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator/Components_DataGrid_MudDataGrid_razor.g.cs(1366,39): error CS1513: } expected [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(14,57): error CS1003: Syntax error, ',' expected [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(14,73): error CS1003: Syntax error, ',' expected [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] ##[debug]Dropping file value '/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.SourceCodeGenerator/MudBlazor.SourceCodeGenerator.FastEnumDescriptionGenerator/OverflowBehaviorMudEnumExtensions.g.cs'. Path does not exist Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.SourceCodeGenerator/MudBlazor.SourceCodeGenerator.FastEnumDescriptionGenerator/OverflowBehaviorMudEnumExtensions.g.cs(25,13): warning CS0618: 'OverflowBehavior.FilpOnOpen' is obsolete: 'This value has a typo and will be removed. Please use FlipOnOpen' [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/Avatar/MudAvatar.razor(7,36): warning CS0618: 'MudAvatar.Image' is obsolete: 'Add a MudImage as the ChildContent instead' [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/Avatar/MudAvatar.razor(9,29): warning CS0618: 'MudAvatar.Image' is obsolete: 'Add a MudImage as the ChildContent instead' [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/Avatar/MudAvatar.razor(9,42): warning CS0618: 'MudAvatar.Alt' is obsolete: 'Add a MudImage as the ChildContent instead' [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/PropertyColumn.cs(28,36): warning CS8618: Non-nullable field '_compiledPropertyFunc' must contain a non-null value when exiting constructor. Consider declaring the field as nullable. [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/PropertyColumn.cs(29,48): warning CS8618: Non-nullable field '_compiledPropertyFuncFor' must contain a non-null value when exiting constructor. Consider declaring the field as nullable. [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(91,150): warning CS8974: Converting method group 'ToggleAsync' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(91,150): warning CS8974: Converting method group 'ToggleAsync' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(95,63): warning CS8974: Converting method group 'HideAllColumnsAsync' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(98,63): warning CS8974: Converting method group 'ShowAllColumnsAsync' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(155,118): error CS0103: The name 'item' does not exist in the current context [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(156,131): error CS0103: The name 'item' does not exist in the current context [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(164,76): error CS0103: The name 'item' does not exist in the current context [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(158,105): error CS0103: The name 'item' does not exist in the current context [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(158,157): error CS0103: The name 'item' does not exist in the current context [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(169,104): error CS0103: The name 'item' does not exist in the current context [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(173,100): error CS0103: The name 'item' does not exist in the current context [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(190,110): error CS0103: The name 'item' does not exist in the current context [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(191,123): error CS0103: The name 'item' does not exist in the current context [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(199,68): error CS0103: The name 'item' does not exist in the current context [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(193,97): error CS0103: The name 'item' does not exist in the current context [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(193,149): error CS0103: The name 'item' does not exist in the current context [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(204,96): error CS0103: The name 'item' does not exist in the current context [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(208,92): error CS0103: The name 'item' does not exist in the current context [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(242,27): error CS0103: The name 'context' does not exist in the current context [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(39,58): error CS0029: Cannot implicitly convert type 'Microsoft.AspNetCore.Components.ElementReference' to 'MudBlazor.MudDropContainer>' [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] ##[debug]Dropping file value '/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Microsoft.NET.Sdk.Razor.SourceGenerators/Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator/Components_DataGrid_MudDataGrid_razor.g.cs'. Path does not exist Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Microsoft.NET.Sdk.Razor.SourceGenerators/Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator/Components_DataGrid_MudDataGrid_razor.g.cs(1351,23): error CS1501: No overload for method 'AddAttribute' takes 4 arguments [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(272,123): warning CS8974: Converting method group 'StringValueChangedAsync' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(277,127): warning CS8974: Converting method group 'NumberValueChangedAsync' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(285,86): warning CS8974: Converting method group 'CancelEditingItemAsync' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(286,86): error CS1503: Argument 2: cannot convert from 'method group' to 'string?' [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(297,37): warning CS8974: Converting method group 'ShowColumnsPanel' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(300,45): warning CS8974: Converting method group 'ExpandAllGroups' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(301,45): warning CS8974: Converting method group 'CollapseAllGroups' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(305,45): warning CS8974: Converting method group 'InvokeServerLoadFunc' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(402,112): warning CS8974: Converting method group 'RemoveFilterAsync' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(405,95): warning CS8974: Converting method group 'FieldChanged' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(425,95): warning CS8974: Converting method group 'StringValueChanged' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(430,99): warning CS8974: Converting method group 'NumberValueChanged' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(437,61): error CS0121: The call is ambiguous between the following methods or properties: 'RenderTreeBuilder.AddContent(int, string?)' and 'RenderTreeBuilder.AddContent(int, RenderFragment?)' [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(435,88): warning CS8974: Converting method group 'EnumValueChanged' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(448,62): error CS0121: The call is ambiguous between the following methods or properties: 'RenderTreeBuilder.AddContent(int, string?)' and 'RenderTreeBuilder.AddContent(int, RenderFragment?)' [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(446,89): warning CS8974: Converting method group 'BoolValueChanged' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(457,89): warning CS8974: Converting method group 'DateValueChanged' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(460,89): warning CS8974: Converting method group 'TimeValueChanged' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(466,95): warning CS8974: Converting method group 'StringValueChanged' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(485,95): warning CS8974: Converting method group 'StringValueChanged' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(490,99): warning CS8974: Converting method group 'NumberValueChanged' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(497,61): error CS0121: The call is ambiguous between the following methods or properties: 'RenderTreeBuilder.AddContent(int, string?)' and 'RenderTreeBuilder.AddContent(int, RenderFragment?)' [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Warning: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(495,88): warning CS8974: Converting method group 'EnumValueChanged' to non-delegate type 'object'. Did you intend to invoke the method? [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] Error: /home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/Components/DataGrid/MudDataGrid.razor(508,62): error CS0121: The call is ambiguous between the following methods or properties: 'RenderTreeBuilder.AddContent(int, string?)' and 'RenderTreeBuilder.AddContent(int, RenderFragment?)' [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor/MudBlazor.csproj::TargetFramework=net7.0] [/home/runner/work/MudBlazor/MudBlazor/src/MudBlazor.Docs/MudBlazor.Docs.csproj] ```

.NET Version

7.0.302

Anything else?

ambigious1

Post update 5/19/2023

Here are some solutions and workarounds for addressing certain errors and warnings:

  1. Multiple components use the tag 'componentName' (RZ9985): See https://github.com/dotnet/razor/issues/8718#issuecomment-1551181634 for more information and avilable workaround.
  2. The attribute names could not be inferred from bind attribute (RZ9991): See https://github.com/dotnet/razor/issues/8725#issuecomment-1554621146 for possible workaround, another options it to try latest NET 8 preview SDK instead.
  3. Found markup element with unexpected name 'componentName'. If this is intended to be a component, add a @using directive for its namespace (RZ10012): Try this workaround https://github.com/dotnet/razor/issues/8718#issuecomment-1553914035, another options it to try latest NET 8 preview SDK instead.
  4. The type or namespace name '' could not be found in the global namespace (are you missing an assembly reference?) (CS0400): Try to specify full qualifier https://github.com/dotnet/razor/issues/8729#issuecomment-1554202661, another options it to try latest NET 8 preview SDK instead.
  5. Cannot implicitly convert type 'Microsoft.AspNetCore.Components.ElementReference' to '[className]' (CS0029): No workaround available except trying the latest NET 8 preview sdk instead or downgrading the SDK to previous version.

Important Note: It is worth mentioning that Microsoft recommends work around the issues by pinning the 7.0.20xx SDK instead.

Downgrading SDK

One potential solution to address the issues caused by the new SDK version is to consider reverting to the previous SDK version: https://github.com/dotnet/razor/issues/8718#issuecomment-1554379109. It's important to note that if you are using containers, you should also ensure that the SDK version is changed accordingly. You may need to update the Dockerfile or related configuration files to specify the desired SDK version, as mentioned in this comment: https://github.com/dotnet/razor/issues/8718#issuecomment-1554556220. Additionally, don't forget to review other areas, such as GitHub workflows, or others CI/CD.

sofiageo commented 1 year ago

I have the same issue with .NET 8 preview 4 and my project.

SpikeViper commented 1 year ago

Having issues with 7.0.302 as well. Getting error CS0400: The type or namespace name 'InputComponent' could not be found in the global namespace (are you missing an assembly reference?) But the imports are definitely there... and it works perfectly in previous versions. Not sure if related to this issue, but certainly related to the same version change.

c4l3b commented 1 year ago

I've experienced a handful of similar issues after installing 7.0.302 (including this one specifically)

For the could not be found in the global namespace issues, if I refactored the not-found, single file component to a component with a separate code-behind class, it fixed the issue. Bizarre.

SpikeViper commented 1 year ago

I've experienced a handful of similar issues after installing 7.0.302 (including this one specifically)

For the could not be found in the global namespace issues, if I refactored the not-found, single file component to a component with a separate code-behind class, it fixed the issue. Bizarre.

Thanks for that info. Are you by any chance using components with inheritance? I think that may be related.

c4l3b commented 1 year ago

Yes! The issue that I can't resolve right now involves an inherited component with a render fragment. The consumer cannot resolve context in the render fragment

ScarletKuro commented 1 year ago

The consumer cannot resolve context in the render fragment

I think we have this issue as well.

c4l3b commented 1 year ago

I was going down the rabbit hole of trying to fix it, but I think I'm going to lock the version to 7.0.202 in my global.json file and wait and see if Microsoft issues a fix. Sounds like some unintended breaking changes...

SpikeViper commented 1 year ago

Looks like the issue is related to passing 'this' in a blazor component to a subcomponent as well in my case... that's where I'm having this pop up.

I'm having it in places without inheritance as well, so there seems to be a few major issues here haha

davidwengier commented 1 year ago

fyi @dotnet/razor-compiler

ScarletKuro commented 1 year ago

We also digged the .g.cs files and found things like this

#line 158 "C:\Users\Riley\source\repos\MudBlazor\src\MudBlazor\Components\DataGrid\MudDataGrid.razor"
                                                                                        rowStyle

#line default
#line hidden
#nullable disable
            ) + "mud-table-row");
            __builder.OpenElement(125, "td");
            __builder.AddAttribute(126, "class", "mud-table-cell");
            __builder.AddAttribute(127, "colspan", "1000");
#nullable restore

notice the ( is flipped Line 158:

<tr class="mud-table-row @rowClass" Style="@rowStyle" @key="item" @onclick="@((args) => OnRowClickedAsync(args, item, tmpRowIndex))">

#nullable disable
            __builder.OpenElement(171, "div");
            __builder.AddAttribute(172, "class", (
#nullable restore
#line 38 "C:\Users\Riley\source\repos\MudBlazor\src\MudBlazor\Components\DataGrid\MudDataGrid.razor"
                                           _tableClass

#line default
#line hidden
#nullable disable
#nullable restore
#line 38 "C:\Users\Riley\source\repos\MudBlazor\src\MudBlazor\Components\DataGrid\MudDataGrid.razor"
                                                                _tableStyle

#line default
#line hidden
#nullable disable
            ) + "mud-table-pagination");
#nullable restore

this one is missing a comma (Line 38 in source)

jjonescz commented 1 year ago

Seems this is another regression introduced by https://github.com/dotnet/razor/pull/8212. Test to reproduce:

[Fact, WorkItem("https://github.com/dotnet/razor/issues/8718")]
public async Task PartialClass()
{
    // Arrange
    var project = CreateTestProject(new()
    {
        ["Shared/Component1.razor"] = """
            <Component2 />
            """,
        ["Shared/Component2.razor"] = """
            @inherits ComponentBase

            @code {
                [Parameter]
                public RenderFragment? ChildContent { get; set; }
            }
            """
    }, new()
    {
        ["Component2.razor.cs"] = """
            using Microsoft.AspNetCore.Components;

            namespace MyApp.Shared;

            public partial class Component2 : ComponentBase
            {

            }
            """
    });
    var compilation = await project.GetCompilationAsync();
    var driver = await GetDriverAsync(project);

    // Act
    var result = RunGenerator(compilation!, ref driver);

    // Assert
    Assert.Empty(result.Diagnostics);
    Assert.Equal(2, result.GeneratedSources.Length);
}

Fails with error:

Shared/Component1.razor(1,1): error RZ9985: Multiple components use the tag 'Component2'. Components: MyApp.Shared.Component2, MyApp.Shared.Component2

(This is one of the errors, my hypothesis is that the other errors reported in this issue are a consequence of it.)

Btw, the workaround seems to be to remove the base class from the codebehind file (since it's also specified in the Razor file), i.e.:

-public partial class Component2 : ComponentBase
+public partial class Component2
tn-5 commented 1 year ago

I'm experiencing a similar issue with inheritance. We defined library components as follows:

The above works fine, except where we reference the derived component in the same project in a razor file. The same error message as noted above is then shown.

If we use the derived components in a different project which references the library project it also works fine.

Needless to say, this scenario worked 100% with preview 3.

ScarletKuro commented 1 year ago

(This is one of the errors, my hypothesis is that the other errors reported in this issue are a consequence of it.)

Btw, the workaround seems to be to remove the base class from the codebehind file (since it's also specified in the Razor file), i.e.:

-public partial class Component2 : ComponentBase
+public partial class Component2

It appears that removing MudBooleanInput<T> from the MudSwitch.razor.cs file resolves the issue and eliminates all errors in MudDataGrid.

ScarletKuro commented 1 year ago

As this issue pertains to broader problems with the new SDK, I would like to compile a list of all the related issues that have been created. Here are the GitHub issues that have been raised regarding the new SDK:

  1. https://github.com/dotnet/razor/issues/8731
  2. https://github.com/dotnet/razor/issues/8727
  3. https://github.com/dotnet/razor/issues/8729
  4. https://github.com/dotnet/razor/issues/8723
  5. https://github.com/dotnet/razor/issues/8724
  6. https://github.com/dotnet/razor/issues/8725
  7. https://github.com/dotnet/aspnetcore/issues/48281
  8. https://github.com/dotnet/razor/issues/8737
  9. https://github.com/dotnet/docs/issues/35449
  10. https://github.com/dotnet/aspnetcore/issues/48327
  11. https://github.com/dotnet/razor/issues/8753
  12. https://github.com/dotnet/razor/issues/8755
  13. https://github.com/dotnet/razor/issues/8761
  14. https://github.com/dotnet/razor/issues/8773
  15. https://github.com/dotnet/aspnetcore/issues/48496
  16. https://github.com/dotnet/aspnetcore/issues/48447
  17. https://github.com/dotnet/razor/issues/8800
  18. https://github.com/dotnet/aspnetcore/issues/48576
  19. https://github.com/dotnet/razor/issues/8822
blake-fm commented 1 year ago

I successfully worked around this* by updating -all- my components to use this structure, whether or not they already had .razor.cs files.

BaseThing.razor

@ No other changes. @


**BaseThing.razor.cs**
- Basically treat as the primary decl., with the `.razor` using only the minimum `@directives` required to compile
- Base class can be e.g. `AnotherBase`, or the framework `ComponentBase`
- Interfaces
```C#
public partial class BaseThing<TThing> : AnotherBase<TThing>, IHasInterfaces {

    // Rest of code as normal - or just an empty class.
}

AnotherBase.cs

public partial class AnotherBase<TThing> : ComponentBase {

    // Rest of code as normal - or just an empty class.
}

*: "this" meaning a whole host of new build errors after installing 17.6 release VS, where 17.5 and 17.6 preview had no issues.

akorchev commented 1 year ago

Another related issue seems to be that inheritance no longer works. The project builds but the component which inherits isn't recognized and renders as html tag. Here is an example:

DbContextPage.razor (base type)

@using RadzenBlazorDemos.Data
@using RadzenBlazorDemos.Models.Northwind
@using Microsoft.EntityFrameworkCore

@inject IDbContextFactory<NorthwindContext> DbFactory

@code {
    protected NorthwindContext dbContext;

    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();

        if (dbContext == null)
        {
            dbContext = await DbFactory.CreateDbContextAsync();
            await dbContext.SeedAsync();
        }
    }
}

Component which no longer works:

@inherits DbContextPage

<div class="rz-p-sm-12 rz-text-align-center">
    <RadzenDropDown TValue="string" Value=@value Data=@companyNames Change="@(args => value = $"{args}")" Style="width: 100%; max-width: 400px;" />
</div>

@code {
    string value = "Around the Horn";
    IEnumerable<string> companyNames;

    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();

        companyNames = dbContext.Customers.Select(c => c.CompanyName).Distinct();
    }
}

Making DbContextPage a c# class works. It is probably related that it contains only a @code block and doesn't render anything.

KrystofZacek commented 1 year ago

It seems that the new source generator wrongly resolves qualified names of types when generating g.cs files. In my case when ComponentA references type from ComponentB (e.g. ComponentB.EnumB) then if I use ComponentA in Index.razor the source generator generates Index_g.cs where ComponentB.EnumB is put to global: namespace leading to error.

image

KrystofZacek commented 1 year ago

image

jjonescz commented 1 year ago

@akorchev @KrystofZacek it seems the issues you are describing were already fixed in https://github.com/dotnet/razor/pull/8614 - unfortunately it looks like that fix didn't make it into .NET 7 SDK but the break did - try if your code works with .NET 8 preview SDK.

akorchev commented 1 year ago

Thank you for the heads up @jjonescz ! Do you think there will be another .NET 7 SDK release that will include dotnet/aspnetcore#8614 and possibly a fix for the current issue? I will try to fix those issues in our code but it is good to know.

gulbanana commented 1 year ago

Recently it's been common for visual studio upgrades to introduce razor bugs, with fixes delayed for a long time. For example, @bind:after was repeatedly broken. It seems like the cadence of integration is resulting in problems being found only after the various SDK builds come together, too late for the solutions to be merged - so the bug goes out into the wild.

dmenoud commented 1 year ago

While waiting for the patch, you install 7.0.203 SDK and add a file named global.json to the root of your solution. This will force the compiler to use the desired version. https://learn.microsoft.com/en-us/dotnet/core/tools/global-json

{ "sdk": { "version": "7.0.203" } }

vladopandzic commented 1 year ago

Also if you have docker file you can use older version by settings this: FROM mcr.microsoft.com/dotnet/aspnet:7.0.4 AS base (for runtime version)

... FROM mcr.microsoft.com/dotnet/sdk:7.0.202 AS build (for SDK)

ScarletKuro commented 1 year ago

Updated the first post with suggested workarounds for specific errors or warnings, as well as other recommendations that have been provided in this or related issues.

333fred commented 1 year ago

Thank you for the heads up @jjonescz ! Do you think there will be another .NET 7 SDK release that will include dotnet/aspnetcore#8614 and possibly a fix for the current issue? I will try to fix those issues in our code but it is good to know.

We expect so. Working on paperwork for reverting the change at the moment.

jcb871 commented 1 year ago

I successfully worked around this* by updating -all- my components to use this structure, whether or not they already had .razor.cs files.

BaseThing.razor

  • Remove any @implements
  • Order of @directives mattered in at least one file (where it did not previously)
@using Namespace
@typeparam TThing
@inherits AnotherBase<TThing>

@* No other changes. *@

BaseThing.razor.cs

  • Basically treat as the primary decl., with the .razor using only the minimum @directives required to compile
  • Base class can be e.g. AnotherBase, or the framework ComponentBase
  • Interfaces
public partial class BaseThing<TThing> : AnotherBase<TThing>, IHasInterfaces {

    // Rest of code as normal - or just an empty class.
}

AnotherBase.cs

public partial class AnotherBase<TThing> : ComponentBase {

    // Rest of code as normal - or just an empty class.
}

*: "this" meaning a whole host of new build errors after installing 17.6 release VS, where 17.5 and 17.6 preview had no issues.

Inherited components were broken after upgrading from 17.5 to (msbuild) 17.6.1. The only fix I needed was to add a code behind for the base component with the class inheriting from ComponentBase.

Thank you

jaredpar commented 1 year ago

Wanted to give everyone an update:

First want to apologize for the regression here. We made a substantial performance improvement to the design / build time experience in Razor that had this particular regression in it that we missed. We're in the process of reverting that change at the moment and it will appear in the next servicing release of the 7.0.3xx .NET SDK. In the mean time advising impacted customers to pin back to the 7.0.2xx SDK. I'll post back here when the fix is published.

This bug also impacts the .NET 8 SDK and will also be patched in it's upcoming release.

Note: the fix is merged on our side. I verified it works for at least one of the repos listed here. Should be all set for next SDK release.

sofiageo commented 1 year ago

Hi @jaredpar maybe it's implied but what about .NET 8? Most if not all issues are also present there.

jaredpar commented 1 year ago

@sofiageo

Hi @jaredpar maybe it's implied but what about .NET 8? Most if not all issues are also present there.

Yes it also impacts .NET 8 as we ship the same compiler in both releases. The fix will also appear in the next .NET 8 SDK update.

ScarletKuro commented 1 year ago

@ScarletKuro I've been attempting to verify the fix with the MudBlazor repo. Running into a > problem reproducing the error in the first place though. The steps I took were:

Clone MudBlazor dotnet new globaljson --sdk-version 7.0.302 cd src dotnet build

Doing that I see MudBlazor building just fine. There are ~117 warnings but no errors. I looked through the GHA build you linked to but don't see anything substantially different from what I'm doing here. Biggest difference is building on Windows vs Linux (going to try that in a bit).

Can you help me figure out what step I'm missing here?

Hello! I noticed that the comment was removed, so I assume you have figured things out. However, in case you haven't or if someone else requires further information, I want to let you know that we have implemented a workaround in https://github.com/MudBlazor/MudBlazor/pull/6872. This workaround addresses the build errors. You need to either revert that commit or reset to a state prior to it. Nevertheless, it's important to note that even with the inclusion of the https://github.com/MudBlazor/MudBlazor/pull/6872 commit, there are still some warnings in the project, such as RZ10012. These warnings are caused by the regression introduced in https://github.com/dotnet/razor/pull/8212.

Varin6 commented 1 year ago

Potentially related. My Pipelines on Azure failed today, running first time on 7.0.302 (for a project using Radzen.Blazor) with those errors:

##[error]C:\devOpsAgent\_work\1\s\Libraries\Radzen.Blazor\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\RadzenDataGridCell_razor.g.cs(566,162): Error CS0307: The namespace '__Blazor.Radzen.Blazor.RadzenDataGridRow' cannot be used with type arguments
C:\devOpsAgent\_work\1\s\Libraries\Radzen.Blazor\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\RadzenDataGridCell_razor.g.cs(566,162): error CS0307: The namespace '__Blazor.Radzen.Blazor.RadzenDataGridRow' cannot be used with type arguments [C:\devOpsAgent\_work\1\s\Libraries\Radzen.Blazor\Radzen.Blazor.csproj]
##[error]C:\devOpsAgent\_work\1\s\Libraries\Radzen.Blazor\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\RadzenGrid_razor.g.cs(3323,158): Error CS0307: The namespace '__Blazor.Radzen.Blazor.RadzenGrid' cannot be used with type arguments
C:\devOpsAgent\_work\1\s\Libraries\Radzen.Blazor\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\RadzenGrid_razor.g.cs(3323,158): error CS0307: The namespace '__Blazor.Radzen.Blazor.RadzenGrid' cannot be used with type arguments [C:\devOpsAgent\_work\1\s\Libraries\Radzen.Blazor\Radzen.Blazor.csproj]
##[error]C:\devOpsAgent\_work\1\s\Libraries\Radzen.Blazor\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\RadzenDataGridRow_razor.g.cs(491,162): Error CS0307: The namespace '__Blazor.Radzen.Blazor.RadzenDataGridRow' cannot be used with type arguments

It was first time running it on this SDK version. I updated my SDK locally to 7.0.302 - project builds fine on my machine.

jaredpar commented 1 year ago

@ScarletKuro

I noticed that the comment was removed, so I assume you have figured things out.

Yeah I removed the comment immediately after posting cause I hadn't tried Linux yet. Wanted to spend a bit more time matching your GHA setup to see if I could work it out myself. But as you pointed out you've already worked around the issue so didn't matter which OS I was using. Thanks for the pointer on the work around. Once I undo that it's easy to reproduce the problem.

jaredpar commented 1 year ago

@ScarletKuro

Thanks for help. Verified broken state prior to your patch on 7.0.302 and verified that our fix does indeed fix the issue.

ghost commented 1 year ago

Guys, please, test this stuff out more before releasing. And, add this as a unit test. I can't imagine how many devs are affected by this issue and banging their heads against the wall, like I am. :( Reverting from 17.6.1 to 17.5.5 fixed the issue for me, however, doing that also reverted a bunch of my Visual Studio settings, including uninstalling extensions that I had installed, that I now have to reset, too. :(

ncikic commented 1 year ago

We are working on rewriting the legacy system (quite big sw developed over 20+ years) and have chosen blazor for it. For now not regretting, but had this unpleasant surprise two days ago. No pressure, just saying that I am counting on you :)

TheCollegedude commented 1 year ago

Though reverting to 7.0.203 resolved the compilation errors, I still have hundreds of lines with red squiggles and hence also autocompletion is gone.

OndrejVrsan commented 1 year ago

@TheCollegedude how did you reverted? Do you use global.config to specify SDK your project should use? We use this configuration to "revert" to earlier SDK with no issues.

{
  "sdk": {
    "version": "7.0.200",
    "rollForward": "latestPatch"
  }
}

https://learn.microsoft.com/en-us/dotnet/core/tools/global-json

ncikic commented 1 year ago

Visual studio installer has some revert button. Hth Nenad

Il Gio 25 Mag 2023, 06:45 Ondrej Vrsan @.***> ha scritto:

@TheCollegedude https://github.com/TheCollegedude how did you reverted? Do you use global.config to specify SDK your project should use? We use this configuration to "revert" to earlier SDK with no issues.

{ "sdk": { "version": "7.0.200", "rollForward": "latestPatch" } }

https://learn.microsoft.com/en-us/dotnet/core/tools/global-json

— Reply to this email directly, view it on GitHub https://github.com/dotnet/razor/issues/8718#issuecomment-1562259147, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGB57DSD2HUWD4Z24PGCD7DXH3PXDANCNFSM6AAAAAAYEV364Y . You are receiving this because you commented.Message ID: @.***>

TheCollegedude commented 1 year ago
{
  "sdk": {
    "version": "7.0.200",
    "rollForward": "latestPatch"
  }
}

@OndrejVrsan I have this:

{ "sdk": { "version": "7.0.203" } }
christallire commented 1 year ago

Just release the freakin fix. Why everyone should reset or adjust all of their dev/CI environment?

tankbob commented 1 year ago

Or can we at least get a timeframe as to when you will be releasing the update?

bobwinners commented 1 year ago

I have the same issue. - .net 7.0.302

TheCollegedude commented 1 year ago
7.0.302

You have to revert your SDK to 7.0.203

tecxx commented 1 year ago

nevermind, rollbacked successfully. looking forward to a fix.

wrharper-AASP commented 1 year ago

this happens in .net 6 as well: https://developercommunity.visualstudio.com/t/Visual-Studio-1762-has-broken-Blazor-C/10382026 & https://github.com/OfficeDev/TeamsFx/issues/8879#event-9445273655

SpikeViper commented 1 year ago

Just release the freakin fix. Why everyone should reset or adjust all of their dev/CI environment?

It has been a long three weeks, but hopefully something is coming soon. More transparency on a timeline would be appreciated for development-breaking issues like this.

AASPLLC commented 1 year ago

couldn't agree more, this is a complete outage to every dev on this version using blazor servers.

333fred commented 1 year ago

this happens in .net 6 as well: https://developercommunity.visualstudio.com/t/Visual-Studio-1762-has-broken-Blazor-C/10382026

This is not because of .NET 6, it's because of VS 17.6. It will be patched in the next servicing release of VS 17.6 - I do not believe I can say anything other than "soon" for this date though.

It has been a long three weeks, but hopefully something is coming soon. More transparency on a timeline would be appreciated for development-breaking issues like this.

This will be part of the next servicing release of .NET 7. Our release cycle for this is documented here: https://github.com/dotnet/core/blob/main/release-policies.md#servicing. Unless something drastic occurs, I expect 7.0.304 to release next patch Tuesday, 6/13.

paulguz-datapa commented 1 year ago

@333fred So you have no facility in your release cycle for quickly patching major breaking regressions? So many production Blazor apps are affected by this. Every newcomer to Blazor who has downloaded it in the last three weeks will be scratching their heads as to why their projects don't build, and forever put off Blazor (maybe even .Net!).

This is the second consecutive big Visual Studio update which has come with breaking Blazor regressions. I'm concerned at the lack of urgency to fix them.

@danroth27 Why is this acceptable?

ghost commented 1 year ago

It's beginning to feel like Blazor Server is going the way of Silverlight. And we've trusted Microsoft yet again. :(

Who is managing Blazor Server? Please get your act together or you are going to lose Devs in droves. I feel horrible for everyone having to waste a ton of time on this issue, only to find this ticket.

We've also been waiting patiently on "Pause and resume Blazor Server circuits (#30344)" for Blazor Server since v5, but this incredibly important ticket was blown off by the team as well. So much for using Blazor Server for professional apps (https://github.com/dotnet/aspnetcore/issues/30344#issuecomment-1532640022). :(

Please! Blazor Server team .... get it together!