I stumbled into an issue with the referenced compiler version being wrong by the analyzer assembly. Luckily the easy fix was to update Visual Studio.
My error i got:
The analyzer assembly 'C:\Program Files\dotnet\sdk\9.0.100-preview.3.24204.13\Sdks\Microsoft.NET.Sdk.Razor\source-generators\Microsoft.CodeAnalysis.Razor.Compiler.dll' references version '4.10.0.0' of the compiler, which is newer than the currently running version '4.9.0.0'.