Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Filtering nullable inner object throws NRE [WASM] #104

Closed
rdadkins opened this issue Apr 10, 2020 · 1 comment
Closed

Filtering nullable inner object throws NRE [WASM] #104

rdadkins opened this issue Apr 10, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@rdadkins
Copy link

I am working with this object template:

public class Outer
{
  public string Id { get; set; }

  public Inner Inner { get; set; }
}

public class Inner
{
  public string Value { get; set; }
}

And this table:

<Table TableItem="Outer">
  <Column TableItem="Outer" Title="Inner value" Field="@(x => x.Inner.Value)" Sortable="true" Filterable="true">
    <Template>
      @if (@context.Inner == null)
      {
        <text>N/A</text>
      }
      else
      {
        <a href="" @onclick="@(() => SomeMethod(@context))" @onclick:preventDefault>@context.Inner.Value</a>
      }
    </Template>
  </Column>
</Table>

The table renders fine and the appropriate string filter is detected. However, whenever Outer.Inner is null, a null reference exception is thrown. If I filter the table before hand to make sure Outer.Inner has values, the exception is not thrown.

Here is the exception:

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] blazor.webassembly.js:1:36074
      Unhandled exception rendering component: Object reference not set to an instance of an object. blazor.webassembly.js:1:36074
System.NullReferenceException: Object reference not set to an instance of an object. blazor.webassembly.js:1:36074
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&) blazor.webassembly.js:1:36074
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x27408c8 + 0x000ce> in <filename unknown>:0 blazor.webassembly.js:1:36074
--- End of stack trace from previous location where exception was thrown --- blazor.webassembly.js:1:36074
<empty string> blazor.webassembly.js:1:36074
  at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion (System.Threading.Tasks.Task task) <0x2dfa1b8 + 0x000e6> in <filename unknown>:0 blazor.webassembly.js:1:36074
  at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask (System.Threading.Tasks.Task taskToHandle) <0x2e00d10 + 0x000c2> in <filename unknown>:0 
@IvanJosipovic IvanJosipovic self-assigned this Apr 14, 2020
@IvanJosipovic IvanJosipovic added the bug Something isn't working label Apr 14, 2020
@IvanJosipovic IvanJosipovic mentioned this issue Apr 18, 2020
IvanJosipovic added a commit that referenced this issue Apr 18, 2020
Improve component accessibility with aria attributes (#106) @LeonarddeR
Fix for colspan with DetailTemplate (#105) @smokedlinq
Fix for Filtering nullable inner object throws NRE [WASM] (#104)
Updated Sample to Blazor 3.2.0 Preview 4
@IvanJosipovic
Copy link
Owner

Thank you for reporting this issue, it should be resolved in v1.8.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants