PrismLibrary/Prism · error · ArgumentNullException

propertyInfo

Error message

propertyInfo

What it means

PropertyObserverNode's constructor requires a PropertyInfo describing the node in the property chain and an Action callback; passing a null PropertyInfo throws ArgumentNullException. The node cannot resolve or subscribe to anything without the property metadata.

Solutions

  1. Pass a valid PropertyInfo obtained from expression.Member with a type check
  2. Guard the expression member is PropertyInfo before constructing the node

Example fix

// before
var node = new PropertyObserverNode(null, callback);
// after
if (expression.Member is PropertyInfo pi)
    var node = new PropertyObserverNode(pi, callback);
Defensive patterns

Strategy: type-guard

Validate before calling

bool ok = member is PropertyInfo pi && pi != null;
// construct PropertyObserverNode only with a resolved PropertyInfo

Type guard

static bool TryGetNode(Expression e, out PropertyInfo pi) { pi = (e as MemberExpression)?.Member as PropertyInfo; return pi != null; }

Try / catch

try { var node = new PropertyObserverNode(pi, action); }
catch (ArgumentNullException) { /* pi was null — expression member was not a property */ }

Prevention

When it happens

Trigger: Constructing PropertyObserverNode directly (or via reflection/tooling) with a null PropertyInfo argument.

Common situations: Custom observers or test code building node chains manually pass null because the expression member was not a PropertyInfo (e.g. a FieldInfo or null member from a malformed expression).

Related errors


AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15). Data as JSON: /api/errors/316bf9074bfaedbc. Report an issue: GitHub.

Appendix: source

Thrown at src/Prism.Core/Commands/PropertyObserverNode.cs:22

#nullable enable
namespace Prism.Commands
{
    /// <summary>
    /// Represents each node of nested properties expression and takes care of 
    /// subscribing/unsubscribing INotifyPropertyChanged.PropertyChanged listeners on it.
    /// </summary>
    internal class PropertyObserverNode
    {
        private readonly Action _action;
        private INotifyPropertyChanged? _inpcObject;

        public PropertyInfo PropertyInfo { get; }
        public PropertyObserverNode? Next { get; set; }

        public PropertyObserverNode(PropertyInfo propertyInfo, Action action)
        {
            PropertyInfo = propertyInfo ?? throw new ArgumentNullException(nameof(propertyInfo));
            _action = () =>
            {
                action?.Invoke();
                if (Next == null) return;
                Next.UnsubscribeListener();
                GenerateNextNode();
            };
        }

        public void SubscribeListenerFor(INotifyPropertyChanged inpcObject)
        {
            _inpcObject = inpcObject;
            _inpcObject.PropertyChanged += OnPropertyChanged;

            if (Next != null) GenerateNextNode();
        }

        private void GenerateNextNode()

View on GitHub (pinned to 358118cd64)