KirillOsenkov / MSBuildStructuredLog

A logger for MSBuild that records a structured representation of executed targets, tasks, property and item values.
MIT License
1.46k stars 198 forks source link

[macos] NRE when searching after loading binlog #523

Closed spouliot closed 3 years ago

spouliot commented 3 years ago

Just updated to b1ecef78bf1a9014d85a7bbc7b86ac606fa32453

When I open a binlog and then type for search I get a NRE

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at StructuredLogViewer.Avalonia.Controls.BuildControl.BuildResultTree(Object resultsObject, Boolean moreAvailable) in /Users/poupou/git/KirillOsenkov/MSBuildStructuredLog/src/StructuredLogViewer.Avalonia/Controls/BuildControl.xaml.cs:line 999
   at StructuredLogViewer.Avalonia.Controls.SearchAndResultsControl.DisplaySearchResults(Object results, Boolean moreAvailable) in /Users/poupou/git/KirillOsenkov/MSBuildStructuredLog/src/StructuredLogViewer.Avalonia/Controls/SearchAndResultsControl.xaml.cs:line 91
   at StructuredLogViewer.Avalonia.Controls.SearchAndResultsControl.searchTextBox_TextChanged(Object sender, AvaloniaPropertyChangedEventArgs e) in /Users/poupou/git/KirillOsenkov/MSBuildStructuredLog/src/StructuredLogViewer.Avalonia/Controls/SearchAndResultsControl.xaml.cs:line 69
   at Avalonia.AvaloniaObject.RaisePropertyChanged[T](AvaloniaPropertyChangedEventArgs`1 change) in /_/src/Avalonia.Base/AvaloniaObject.cs:line 758
   at Avalonia.AvaloniaObject.RaisePropertyChanged[T](AvaloniaProperty`1 property, Optional`1 oldValue, BindingValue`1 newValue, BindingPriority priority) in /_/src/Avalonia.Base/AvaloniaObject.cs:line 676
   at Avalonia.AvaloniaObject.SetAndRaise[T](AvaloniaProperty`1 property, T& field, T value) in /_/src/Avalonia.Base/AvaloniaObject.cs:line 701
   at Avalonia.Controls.TextBox.SetTextInternal(String value) in /_/src/Avalonia.Controls/TextBox.cs:line 1204
   at Avalonia.Controls.TextBox.HandleTextInput(String input) in /_/src/Avalonia.Controls/TextBox.cs:line 540
   at Avalonia.Controls.TextBox.OnTextInput(TextInputEventArgs e) in /_/src/Avalonia.Controls/TextBox.cs:line 507
   at Avalonia.Input.InputElement.<>c.<.cctor>b__30_4(InputElement x, TextInputEventArgs e) in /_/src/Avalonia.Input/InputElement.cs:line 204
   at System.Reactive.Subjects.Subject`1.OnNext(T value) in /_/Rx.NET/Source/src/System.Reactive/Subjects/Subject.cs:line 145
   at Avalonia.Interactivity.EventRoute.RaiseEventImpl(RoutedEventArgs e) in /_/src/Avalonia.Interactivity/EventRoute.cs:line 148
   at Avalonia.Interactivity.EventRoute.RaiseEvent(IInteractive source, RoutedEventArgs e) in /_/src/Avalonia.Interactivity/EventRoute.cs:line 79
   at Avalonia.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e) in /_/src/Avalonia.Interactivity/Interactive.cs:line 121
   at Avalonia.Input.KeyboardDevice.ProcessRawEvent(RawInputEventArgs e) in /_/src/Avalonia.Input/KeyboardDevice.cs:line 245
   at Avalonia.Input.InputManager.ProcessInput(RawInputEventArgs e) in /_/src/Avalonia.Input/InputManager.cs:line 37
   at Avalonia.Native.WindowBaseImpl.RawTextInputEvent(UInt32 timeStamp, String text) in /_/src/Avalonia.Native/WindowImplBase.cs:line 261
   at Avalonia.Native.WindowBaseImpl.WindowBaseEvents.Avalonia.Native.Interop.IAvnWindowBaseEvents.RawTextInputEvent(UInt32 timeStamp, String text) in /_/src/Avalonia.Native/WindowImplBase.cs:line 202
   at Avalonia.Native.Interop.Impl.__MicroComIAvnWindowBaseEventsVTable.RawTextInputEvent(IntPtr this, UInt32 timeStamp, Byte* text) in /_/src/Avalonia.Native/Interop.Generated.cs:line 3217
--- End of stack trace from previous location ---
   at Avalonia.Native.PlatformThreadingInterface.RunLoop(CancellationToken cancellationToken) in /_/src/Avalonia.Native/PlatformThreadingInterface.cs:line 90
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken) in /_/src/Avalonia.Base/Threading/Dispatcher.cs:line 61
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args) in /_/src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs:line 116
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode) in /_/src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs:line 148
   at StructuredLogViewer.Avalonia.Program.Main(String[] args) in /Users/poupou/git/KirillOsenkov/MSBuildStructuredLog/src/StructuredLogViewer.Avalonia/Program.cs:line 9

I worked around it locally (so far, so good) with

diff --git a/src/StructuredLogViewer.Avalonia/Controls/BuildControl.xaml.cs b/src/StructuredLogViewer.Avalonia/Controls/BuildControl.xaml.cs
index 9e69254..4b42e6c 100644
--- a/src/StructuredLogViewer.Avalonia/Controls/BuildControl.xaml.cs
+++ b/src/StructuredLogViewer.Avalonia/Controls/BuildControl.xaml.cs
@@ -996,7 +996,7 @@ Recent:
                 folder.AddChildAtBeginning(showAllButton);
             }

-            return folder.Children;
+            return folder?.Children;^M
         }

         private void TreeViewItem_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
KirillOsenkov commented 3 years ago

Thanks, fixed.