Skip to content

Error in LayoutComponent breaks at the wrong location. #14618

@RichardB01

Description

@RichardB01

If you have an error in the properties of a layout component, the error appears at the parent razor page include line instead of the actual error location.

Example:

Index.razor (this is where the error breaks at):
<MyProject.PrintMessage ParameterMessage="@Message"/>

PrintMessage.razor (where the real error is):


public static string LowercaseMessage = "";

     // route the given parameters to static, this is because our JSInvokables are static.
    public static string Message = "";
    [Parameter]
    public string ParameterMessage
    {
        get
        {
            return Message;
        }
        set
        {
             LowercaseMessage = Message.ToLower();   // <--------- this is the real error here since Message is undefined.

            Message = value;
        }
    }

... razor code ..

 [JSInvokable]
    public static string OnMouseClickPrintMessage()
    {
        string message = LowercaseMessage;

        // do something with message
    }
`

This is the error when you try to load the <MyProject.PrintMessage ParameterMessage="@message"/> razor snippet.
devenv_gW2iccCo1l
Notice that this error is appearing at this.StateHasChanged() and not at "PrintMessage.razor"

Metadata

Metadata

Assignees

Labels

✔️ Resolution: FixedThe bug or enhancement requested in this issue has been checked-in!area-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions