Skip to content
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

BuildRenderTree does not get called in Preview 4 #9857

Closed
DerekChasse opened this issue Apr 30, 2019 · 2 comments
Closed

BuildRenderTree does not get called in Preview 4 #9857

DerekChasse opened this issue Apr 30, 2019 · 2 comments
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: By Design Resolved because the behavior in this issue is the intended design.

Comments

@DerekChasse
Copy link

Describe the bug

I've added a simple component which overrides BuildRenderTree and attempts to wrap ChildContent in a simple <div>. I've more complex logic in a real-world usage, but this simple test demonstrates the issue.

I'm wondering if this is related to the ix for #8192

To Reproduce

See reproducible demo here:
https://github.com/DerekChasse/BuildRenderTree

Index.razor has a <p> tag which should, as part of rendering the TestComponent, be wrapped in a <div> and that <div> should have a GUID identifier as a simple test of AddAttribute.

Expected behavior

I would expect that, as in preview 0.9.0 calls to the overridden BuildRenderTree be honored.

Screenshots

image

Additional context

There is also simple logging with Console.Writeline in the BaseIndex baseclass which was previously honored in and is no longer being called.

Visual Studio 16.1.0 Preview 2.0
dotnet 3.0.100-preview4-011223

@Eilon Eilon added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Apr 30, 2019
@chrissainty
Copy link
Contributor

chrissainty commented Apr 30, 2019

@DerekChasse I've messaged you on Gitter as well but this looks to be an issue with your code.

You've overridden BuildRenderTree in a base class, TestComponentBase.cs, which is inherited by TestComponent.razor but you've also specified markup in TestComponent.razor file.

I believe the razor code will override your code in BuildRenderTree hence you are not seeing the expected outcome.

Generally, I would not write code in BuildRenderTree and would try and stick to razor.

@mkArtakMSFT mkArtakMSFT added the area-blazor Includes: Blazor, Razor Components label May 1, 2019
@mkArtakMSFT mkArtakMSFT removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels May 9, 2019
@rynowak
Copy link
Member

rynowak commented May 26, 2019

The explanation from @chrissainty is correct. Generated Razor code will replace override BuildRenderTree() and will not call call base.BuildRenderTree(). This is the intended behavior, we want to make it possible to subclass a component and totally replace its markup.

@rynowak rynowak closed this as completed May 26, 2019
@rynowak rynowak added the ✔️ Resolution: By Design Resolved because the behavior in this issue is the intended design. label May 26, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: By Design Resolved because the behavior in this issue is the intended design.
Projects
None yet
Development

No branches or pull requests

5 participants