-
-
Notifications
You must be signed in to change notification settings - Fork 234
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
BlazorSetParametersSourceGenerator interferes with capturing CascadedEditContext
#9682
Comments
@ShahryarSaljoughi Thanks for contacting us. |
@msynk The InputBase is the one that is defined in |
@msynk The InputBase is the one that is defined in I'll provide a repo reproducing the issue by Monday. |
@ShahryarSaljoughi I think I understand the issue now. I will try modifying our source generator to only work on the |
The issue is accepted and planned. Resolving it will start ASAP. |
Resolving this issue has started. It will be announced when this issue is resolved. |
@msynk Isn't the generated source code an optimization best practice? If that's the case, isn't it possible to resolve the issue such that we can still have those optimized auto generated methods for all our components? If the source generator is to be restricted to |
It's not going to work for components that are not implemented based on our standards, such as those that inherit from other base components. and we are not using this specific source generator anywhere else. |
None of the types outside of the bit NuGet packages are likely to belong to the |
by |
Aha thank you. I see your point clearly, however, the generator which is affecting other components is the |
yes, I'm aware of that problem too. I'm thinking of another solution for that one now. |
Could you delegate this task, to me? |
I don't think we can do much about it since the |
Is there an existing issue for this?
Describe the bug
Let's say I have a component which derives from
InputBase<string?>
. The protectedEditContext
property of my component (which is declared within theInputBase<T>
class) will not be initialized properly ifBit.SourceGenerator.BlazorSetParametersSourceGenerator
generates theSetParametersAsync
method for my component.Current Workaround:
I can prevent the source generator from generating
SetParametersAsync
for my component by implementing theSetParametersAsync
myself:Lines of Code Related to the Issue:
Here is a part of the generated code:
It first creates a
Dictionary
out ofparameters
and then at the end converts back the dictionary back toParameterView
object. During this forth and back conversion the cascaded parameters are lost! The image below confirms this loss:As you can see in the image above, the
parametersFromDictionary
does not contain the cascaded parameters, though the initialparameters
instance contained the cascaded edit context parameter.Steps To Reproduce
Step 1: define the custom component, as partial class with code behind:
TextInput.razor:
TextInput.razor.cs
Step two: Use the component within an
EditForm
:Step three: Note the bug:
EditContext
is not initialized (null
) and validation errors are not shown.OnFieldChanged
event ofEditContext
is not firedExceptions (if any)
No response
.NET Version
8.0.300
Anything else?
No response
The text was updated successfully, but these errors were encountered: