Blazor-Diagrams / Blazor.Diagrams

A fully customizable and extensible all-purpose diagrams library for Blazor
https://blazor-diagrams.zhaytam.com
MIT License
917 stars 176 forks source link

NullReferenceException in `DiagramCanvas.OnInitialized()` on .NET 8 #424

Closed Joe4evr closed 3 months ago

Joe4evr commented 3 months ago

Found while upgrading a company codebase to .NET 8, rendering a DiagramCanvas always triggers NRE.

Error: System.NullReferenceException: Object reference not set to an instance of an object.
   at Blazor.Diagrams.Components.DiagramCanvas.OnInitialized()
   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()

Looking at the implementation of DiagramCanvas.OnInitialized, the only thing would reasonably be causing the NRE is BlazorDiagram.Changed += OnDiagramChanged;. I can confirm the diagram that we pass in is non-null, but it's also pretty sus that that line isn't in OnParametersSet instead.

In fact, I'm amazed that all of this worked at all previously, since the DiagramCanvas hasn't been touched for 2 years, and Blazor's initialation logic hasn't been touched in 3 years (meaning it has always called OnInitialized() before OnParametersSet()).

This is blocking our upgrade to .NET 8, and that in turn is blocking other work items.

Joe4evr commented 3 months ago

Sigh Nevermind, seems like I didn't catch having to change our diagram field being typed as Diagram to BlazorDiagram. 🤦

zHaytam commented 3 months ago

That's what I was gonna say, but got caught up at work sorry!