blazor.net-8.0csproj

Mysterious forced .csproj elements for Blazor components (App.razor)


Since I put my App.razor's @code into an App.razor.cs file, Visual Studio stuffed this crap into my .csproj file. Removing it gives these compile errors: depiction of diff and compile errors

Here's the contents App.razor, just in case:

    using MyProject.Client.Services;
    using MyProject.Data;
    using System.Data;
    using System.Text;
    
    namespace MyProject.Components;

    public partial class App : ComponentBase {
        [Inject]
        private ServerDbAccess Db { get; set; } = null!;
        [Inject]
        private ServerSessionData SessionData { get; set; } = null!;

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

            IDbConnection dbCon = await this.Db.ConnectDb_Async();

            await this.SessionData.Load_Async( dbCon );
        }
    }

Any idea what's going on?


Solution

  • Despite the confusing output information, it seems the issue was simply a missing using (using Microsoft.AspNetCore.Components;), which wasn't being caught because of the way the compilation was working before. I wasn't getting the missing reference alert in the IDE until I reloaded after cleaning the project. Possibly an IDE bug?