Description
If a component is added to the compilation by a source generator, it is recognised by intellisense correctly, and will render correctly if referenced in c# code e.g. OpenComponent<MyComponent>(1)
, but triggers a warning and does not render if referenced in markup e.g. <MyComponent/>
Filed using Visual Studio feedback here : https://developercommunity.visualstudio.com/t/Razor-Components-which-are-added-by-a-3r/1400911
The problem can be seen in the generated code attached and on the feedback issue:
_Pages_Index.razor.cs.zip
In the C# @code
section of the razor file, it correctly allows use of the component class:
b.OpenComponent<Component1>(1);
b.CloseComponent();
But in the code generated from the Razor markup, it turns the component into an element
__builder.OpenElement(8, "Component1");
__builder.CloseElement();
Sample repo: https://github.com/SQL-MisterMagoo/SGProblem
Clone it
git clone https://github.com/SQL-MisterMagoo/SGProblem.git
Run itdotnet run --project SampleWASM\SampleWASM.csproj
Environment:
Microsoft Visual Studio Enterprise 2019 Preview
Version 16.10.0 Preview 2.1
.NET SDK 6.0.100-preview.3.21202.5