-
-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blazor wasm projects not including .razor files #200
Comments
I'm going to guess there's a lot of magic involved in the codegen for Blazor WASM, though I haven't looked too closely at it. If so, I'm not surprised we're not seeing everything. Note that Buildalyzer primarily looks for the source files that get sent to In any case, I'm not sure whether to call this a bug, or just unsupported at this point. Do you have a simple reproduceable use case I can look at? |
Repro is attached. The source generation does not really have anything to do with wasm. CS files are generated from the razor files and compiled into the assembly. The mono clr running in wasm then interprets them at runtime, at least in development mode. AOT may be done on a publish but should not be triggered for a normal debug build. I believe with Blazor 5 or 6 the code generation was switched to use source generators. This can be switched off in the project file (I have commented out the property to do this). Even with this switched off and the source files being generated to disk in obj they are still not picked up. I also added a razor class library project which shows the same issue. Again the razor class library should just be doing a straight compile on the generated cs files. This shows the same results as the BlazorWasmTest. Let me know if you have any other questions on the Blazor side of things. I'm not an expert but I think I have a decent understanding of it. Thanks for taking the time to look at this. |
I'm seeing the same thing. All the other files are picked up except the razor files. Seems like this would break any project that uses razor files. |
I finally got a chance to run through the repro you attached, thanks a lot for that - it makes this much clearer! I think the issue here (if it can even be called an issue) is what the expectation is. It sounds like you were expecting Buildalyzer to see and report on the generated C# files that the Razor/Blazor compiler emits as part of the build and caching process. That's likely out of scope for Buildalyzer the same way looking at the generated source from Supporting such a scenario would require some pretty significant changes under the hood. What Buildalyzer does is run MSBuild out of process while injecting a custom logger that sends logging events from MSBuild back to Buildalyzer for capture. In particular, Buildalyzer looks for an MSBuild task called Let's look at the RazorClassLibraryTest project with and without the source generators. Generating a binlog and viewing it in Structured Log Viewer with the default behavior shows that the file is passed into That's surprising to me and suggests that the Blazor code generator must know how to read a So when using the default Blazor code generation method, Blazor doesn't ever see the generated code because MSBuild doesn't ever see the generated code. If we change the project file to include And that lines up with what Buildalyzer sees and reports: Which raises the question: what happened to the To answer that let's go back to the binlog and search for it. I found it being used in a That seems to suggest that there's a So where does that leave us? It looks like in both scenarios, with and without Roslyn code generators, the compiler (or more likely, an extension to the compiler like an analyzer) is taking the Blazor code and adding it to the compilation. That makes the process outside the scope of what Buildalyzer can see. We could potentially expose these Would that be helpful? To be honest, even if we could find the generated source files for the Razor components, and assuming they even get written to disk somewhere (which I'm not certain about), I'm not sure that passing them into the Roslyn Workspace you get by calling |
I've added Thanks for sticking with me as I worked through this one! |
Sounds good. I really appreciate your help. Thanks. |
I'm attempting to generate an adhoc workspace for a .NET 6 Blazor wasm project but Buildalyzer does not seem to pickup the razor files or their generated code. I'm not sure if this is a bug or something that is not supported. It seems like something that would be a useful feature. Thanks.
The text was updated successfully, but these errors were encountered: