dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.37k stars 9.99k forks source link

Blazor WASM, 6.0 preview 4, trimming too aggressive #33223

Closed sjohag closed 3 years ago

sjohag commented 3 years ago

Describe the bug

When using preview 4 I get an error in published app, not when debugging in VS and not when using the latest stable version. Adding <PublishTrimmed>false</PublishTrimmed> to project file also works. The app has custom input components, inheriting from InputBase<TValue> or one of the built in input components.

I get errors like this. Unhandled exception rendering component: Cannot provide a value for property 'CascadedEditContext' on type X because the property has no setter. Unhandled exception rendering component: The type X declares a parameter matching the name 'ParsingErrorMessage' that is not public.

Even when using a very simple custom component like this: public class MyInputNumber : InputNumber<int> { }

To Reproduce

Create a Blazor WASM app in VisualStudio from template, using preview 4. Add MyInputNumber component. Use it in one of the existing pages like this:

<EditForm Model="this"> <MyInputNumber @bind-Value="add" /> </EditForm> @code { private int add = 1; }

Publish the app to e.g. Azure App Service

Further technical details

6.0.0-preview.4.21253.5, SDK 6.0.100-preview.4.21255.9

pranavkm commented 3 years ago

Thanks for the issue report @sjohag. I suspect this is a dupe of https://github.com/mono/linker/issues/2059 that is being fixed as part of 6.0-preview5. If you'd like you could try grabbing a nightly build of the preview5 or newer SDK from https://github.com/dotnet/installer#installers-and-binaries and see if that addresses the issue. If it does not, we'd be happy to investigate this further.

sjohag commented 3 years ago

@pranavkm I tried with preview 6, seems to work as expected, thank you!