NullReferenceException on ParameterInfoSession.Open() if item collection is empty

SyntaxEditor for WPF Forum

Posted 4 months ago by Dirk Zellerfeld
Version: 19.1.0681
Platform: .NET Core 3.0
Environment: Windows 10 (64-bit)
Avatar

Calling ParameterInfoSession.Open throws a nullreference exception if the item collection is empty. The source code of the sample application is not clear about that. For example in ActiproSoftware.ProductSamples.SyntaxEditorSamples.QuickStart.GettingStarted11 and also in ActiproSoftware.ProductSamples.SyntaxEditorSamples.QuickStart.GettingStarted09 it does not check if Items.Count > 0 like it does in ActiproSoftware.ProductSamples.SyntaxEditorSamples.QuickStart.GettingStarted10

While it kinda makes sense to not call the open method if the item collection is empty, I would suggest adding this check on your end in the open method. Because even though it make no sense, it's still not expected to throw rather than immediately returning from the call. What are your thoughts?

Code to reproduce

private static ParameterInfoSession Session = new ParameterInfoSession();
public override bool RequestSession(IEditorView view, bool canCommitWithoutPopup)
{
    //...
    Session.Items.Clear();
    Session.Open(...)
}
System.NullReferenceException: 'Object reference not set to an instance of an object.'

at ActiproSoftware.Windows.Controls.SyntaxEditor.IntelliPrompt.Implementation.ParameterInfoSession.OnClosed(CancelEventArgs e)
at ActiproSoftware.Windows.Controls.SyntaxEditor.IntelliPrompt.Implementation.IntelliPromptSessionBase.Close(Boolean cancelled)
at ActiproSoftware.Windows.Controls.SyntaxEditor.IntelliPrompt.Implementation.IntelliPromptSessionBase.Open(IEditorView view, TextRange textRange)

Comments (1)

Answer - Posted 4 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Dirk,

Thanks for letting us know about this.  We've fixed the problem on our side for the next maintenance release.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.