Description
I've spent an inordinate amount of time trying to work out why generating an event handler for @bind-Value:set
doesn't work in our cohosting tests and I've finally gotten to the bottom of it.
This test:
In the regular tooling code we discover tag helpers by creating a TagHelperDescriptorProviderContext
with no target symbol, here:
In the source generator when finding tag helpers in references, the assembly symbol is used as the target symbol:
However, when the BindTagHelperDescriptorProvider
runs, if the target symbol isn't null, it won't run unless the target symbol (ie assembly) is the same assembly as Microsoft.AspNetCore.Components.BindConverter
is defined in. BindConverter
is contained in Microsoft.AspNetCore.Components.dll
and all of the standard components, like InputText
etc., are in Microsoft.AspNetCore.Components.Web.dll
.
Changing the source generator to pass null
as the target symbol makes the test pass, but it also makes things take a lot longer. Removing the logic in BindTagHelperDescriptorProvider
also works, but there is a test that specifically validates the behaviour:
I'm guessing things work fine at runtime because the tag helpers are only in place to help tooling. I can't personally see any reason to keep the logic in BindTagHelperDescriptorProvider
but maybe someone else has some more context. I removed it and checked that the generate methods tests pass, but I haven't run all of the rest of the compiler tests to know if there is any other impact.