dotnet / Scaffolding

Code generators to speed up development.
MIT License
620 stars 218 forks source link

Scaffolding in Blazor is unaware of (implicit inheritance?) #2757

Open eberleitguy opened 1 month ago

eberleitguy commented 1 month ago

I'm not amazing at searching, but i didn't find anything similar to my eyes. Apologies in advance if i overlooked.

This bug is pretty simple. When using the Quick Action "Extract block to code-behind", the resulting code-behind doesn't have explicitly defined inheritance, and appears, in the file, to be a bare class. Of course, blazor is all fancy and happily runs, for the most part, despite this. (not clear why, i did get into a couple of states where roslyn was underlining these "incorrect" methods, but a restart of VS returned functionality).

image

image

Find a screen-to-gif of the issue in action below.

For the most part i was following Dan Roth's Blazor front end youtube series (Starting here: https://www.youtube.com/watch?v=sIIfnGqEIds) , but early on took the path of extracting the "Counter" c# code to a codebehind file. I ran into the issue much later when i was following along with the scaffolding in video 9. ScaffoldingProblem

Find entire sample project attached.

There are branches tagging the specific problems. TrainingSample.zip

Environment:

Microsoft Visual Studio Community 2022 Version 17.9.7 VisualStudio.17.Release/17.9.7+34902.65 Microsoft .NET Framework Version 4.8.09032

Installed Version: Community

ASP.NET and Web Tools 17.9.199.22661 ASP.NET and Web Tools

Azure App Service Tools v3.0.0 17.9.199.22661 Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools 17.9.199.22661 Azure Functions and Web Jobs Tools

C# Tools 4.9.0-3.24121.1+a98c90d56455379836dd5c845b35fa932b00cfa3 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

NuGet Package Manager 6.9.2 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Razor (ASP.NET Core) 17.9.2.2412004+684740676513b3b208d5bd5b7f8786dab8d287b7 Provides languages services for ASP.NET Core Razor.

SQL Server Data Tools 17.9.56.1 Microsoft SQL Server Data Tools

TypeScript Tools 17.0.30103.2001 TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 4.9.0-3.24121.1+a98c90d56455379836dd5c845b35fa932b00cfa3 Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 17.9.0-beta.23614.3+a521e1cd420beb56c15faf6836184fadd2b7937a Microsoft Visual F# Tools

Visual Studio IntelliCode 2.2 AI-assisted development for Visual Studio.

OS Info: WIndows 11 Home 22H2 Build 22521.2283