0
votes

I do everything in the documentation, but it's not working. Parameter @context is unknown. What do I wrong? Is this an april's fool? documentation is last updated 3/13/2020 so it's unlikely to be an april's fool.

Edit: For those of you who face the same 'problem': Answer: Just ignore it or turn off resharper code analysis. The displayed error will be gone. It compiles anyways.

Microsoft Documentation

I am referring to this:

@typeparam TItem

<table class="table">
    <thead>
        <tr>@TableHeader</tr>
    </thead>
    <tbody>
        @foreach (var item in Items)
        {
            <tr>@RowTemplate(item)</tr>
        }
    </tbody>
    <tfoot>
        <tr>@TableFooter</tr>
    </tfoot>
</table>

@code {
    [Parameter]
    public RenderFragment TableHeader { get; set; }

    [Parameter]
    public RenderFragment<TItem> RowTemplate { get; set; }

    [Parameter]
    public RenderFragment TableFooter { get; set; }

    [Parameter]
    public IReadOnlyList<TItem> Items { get; set; }
}
<TableTemplate Items="pets">
    <TableHeader>
        <th>ID</th>
        <th>Name</th>
    </TableHeader>
    <RowTemplate>
        <td>@context.PetId</td>
        <td>@context.Name</td>
    </RowTemplate>
</TableTemplate>

variable @context is unknown. what is the problem?

1

1 Answers

1
votes

It turned out, that the code compiles and the problem of displaying "cannot resolve symbol '@context' was caused by Resharper, which obviously does not understand this concept.

After I turned off "Resharper code analysis", the term "@context" turned into normal color. coloration of unknown variables is a feature of resharper.

Gosh, this cost me 2-3 hours. Thanks Jetbrains!

Problem solved.