-
Notifications
You must be signed in to change notification settings - Fork 199
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
Compile-time warning/errors when passing unknown parameters to components that don't accept AdditionalAttributes #11114
Comments
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. |
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. |
Thanks for contacting us. We're moving this issue to the |
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. |
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. |
This is really starting to bite us developers. When a Blazor component renames or removes a parameter, we get no warnings at compile time. This is incredibly frustrating when working with newer versions of third-party components that have removed or renamed parameters. Often, we only get exceptions at runtime. :( Can we please enable a compiler warning when a Blazor component is given a parameter that is invalid? |
@gabephudson While waiting for this rule to be builtin, you can use |
Thank you! The MudBlazor team pointed me to this fantastic package yesterday, as they have a lot of breaking changes in their new release. Many of their parameters have changed and it is difficult to track down all of these in our large codebase. That said, I have added this to our project and while it has highlighted internal components with this issue, it does not seem to be catching this on instances of the MudBlazor components. (Note MudBlazor is a NuGet package in the project). Any idea of why this might be. (It's probably just my ignorance). Either way, it's a fantastic tool and thank you for sharing! |
@gabephudson Please open an issue: https://github.com/meziantou/Meziantou.Analyzer/issues/new/choose |
|
Is your feature request related to a problem? Please describe.
We sometimes get caught by errors in tags, properties etc.
Using the new project sample code and converting the counter p tag to a component
Which we then erroneously reference in our page:
(I appreciate the third would show a warning, but in the event of a rename/move/refactor this may go unnoticed, especially as you sometimes get false errors that are ignored).
In more complex cases you can end up with a compile error in the render tree, which feels almost completely disconnected from the source of the error.
The beauty of Blazor is that it's all in C# and benefits from type safety etc., so frustrating that these errors can slip through to runtime.
Describe the solution you'd like
It would be good to use another syntax that isn't tangled up with html to tell the compiler/parser that you are clearly working with a component so enforces type safety, such as prefixing the tag with a @. Something like:
This would then fail if you used this syntax on lines 2 and 3 above.
Only issue would be attribute splatting, which you could then either use the less safe html format, or maybe have a field where you have to pass the extras in some form of dynamic array.
I understand the familiar use of tags with respect to broad development teams of designers and coders, but as a coder I'd appreciate the added robustness.
Blazor is already doing this under the hood, just not tying loose ends.
Additional context
Not sure this is correct syntax for the render tree (other than it works), as a simple proof of concept I put a static Render method in MyCounter
Appreciate I'm passing my parameter in the method call (which isn't a bad thing because in this case it's required), but I can use
From my page. Compile error checked and safely survives renames, refactors etc.
The text was updated successfully, but these errors were encountered: