Open danroth27 opened 1 year ago
@danroth27 would this be a tooling/compiler ask? (Like a warning/analyzer).
I doubt we would want to put something inside the runtime for this.
@danroth27 would this be a tooling/compiler ask? (Like a warning/analyzer). I doubt we would want to put something inside the runtime for this.
That's my thinking too. But I filed the issue here first so that we could discuss the right way to approach this problem in triage.
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
Moving this to compiler for a first look (though maybe its an LDM thing?).
Or could we add this using directive as an implicit using for the Razor SDK? Or maybe just the Web and Blazor WebAssembly SDKs?
I think this makes heaps of sense, even if its just the compiler always emiting a using directive based on language version or something. Personally I think _Imports.razor
as a concept could stand to disappear now that we have implicit usings in the SDK, and global usings in C#. But that might be too bold 😁
A using directive for the Microsoft.AspNetCore.Components.Web namespace is required to get the web related Razor directives to work (like
@onclick
and friends). We add this using directive in our templates, but occasionally users still get tripped up by not having it. For example, I helped someone who was following the Blazor Hybrid tutorials for WPF & WinForms, but they messed up the name of their _Imports.razor file. The app compiled and ran but a bunch of the Razor directives didn't work. I've seen users also start with a Razor Class Library configured with Pages & View and then try to add Blazor components to it run into this problem.Can we provide better diagnostics for this situation, where users have the web related Razor directives in their code, but they are missing the using directive?
Or could we add this using directive as an implicit using for the Razor SDK? Or maybe just the Web and Blazor WebAssembly SDKs?