{"record":{"id":"8275822f1df54910","repo":"PrismLibrary/Prism","slug":"propertyexpression","errorCode":null,"errorMessage":"propertyExpression","messagePattern":"propertyExpression","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Prism.Core/Mvvm/PropertySupport.cs","lineNumber":28,"sourceCode":"    ///</summary>\n    public static class PropertySupport\n    {\n        /// <summary>\n        /// Extracts the property name from a property expression.\n        /// </summary>\n        /// <typeparam name=\"T\">The object type containing the property specified in the expression.</typeparam>\n        /// <param name=\"propertyExpression\">The property expression (e.g. p => p.PropertyName)</param>\n        /// <returns>The name of the property.</returns>\n        /// <exception cref=\"ArgumentNullException\">Thrown if the <paramref name=\"propertyExpression\"/> is null.</exception>\n        /// <exception cref=\"ArgumentException\">Thrown when the expression is:<br/>\n        ///     Not a <see cref=\"MemberExpression\"/><br/>\n        ///     The <see cref=\"MemberExpression\"/> does not represent a property.<br/>\n        ///     Or, the property is static.\n        /// </exception>\n        public static string? ExtractPropertyName<T>(Expression<Func<T>> propertyExpression)\n        {\n            if (propertyExpression == null)\n                throw new ArgumentNullException(nameof(propertyExpression));\n\n            return ExtractPropertyNameFromLambda(propertyExpression);\n        }\n\n        /// <summary>\n        /// Extracts the property name from a LambdaExpression.\n        /// </summary>\n        /// <param name=\"expression\">The LambdaExpression</param>\n        /// <returns>The name of the property.</returns>\n        /// <exception cref=\"ArgumentNullException\">Thrown if the <paramref name=\"expression\"/> is null.</exception>\n        /// <exception cref=\"ArgumentException\">Thrown when the expression is:<br/>\n        ///     The <see cref=\"MemberExpression\"/> does not represent a property.<br/>\n        ///     Or, the property is static.\n        /// </exception>\n        internal static string? ExtractPropertyNameFromLambda(LambdaExpression expression)\n        {\n            if (expression == null)\n                throw new ArgumentNullException(nameof(expression));","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Prism.Core/Mvvm/PropertySupport.cs#L10-L46","documentation":"PropertySupport.ExtractPropertyName throws ArgumentNullException when the 'propertyExpression' lambda is null. The method extracts a property name from an Expression<Func<T>>, so a null expression has no property to inspect.","triggerScenarios":"Calling PropertySupport.ExtractPropertyName<T>(null) — usually when the expression came from a variable that was never assigned, or a helper method forwarded a null parameter.","commonSituations":"MVVM helpers computing property names for PropertyChanged notifications; generic base classes whose callers forgot to pass the expression.","solutions":["Pass a valid member-access lambda such as () => this.SomeProperty","Null-check the expression at your own helper boundary before forwarding","Prefer nameof(SomeProperty) when compile-time name capture suffices (no expression needed)"],"exampleFix":"// before\nvar name = PropertySupport.ExtractPropertyName((Expression<Func<string>>)null);\n// after\nvar name = PropertySupport.ExtractPropertyName(() => ViewModel.Title);","handlingStrategy":"type-guard","validationCode":"if (propertyExpression == null)\n    throw new ArgumentException(\"A property expression is required\");","typeGuard":"bool IsPropertyExpression<T>(Expression<Func<T>> expr) =>\n    expr != null && expr.Body is MemberExpression { Member: PropertyInfo };","tryCatchPattern":"try\n{\n    var name = PropertySupport.ExtractPropertyName(() => vm.Title);\n}\ncatch (ArgumentNullException ex)\n{\n    logger.LogError(ex, \"Property expression was null\");\n}","preventionTips":["Use nameof() when a compile-time name suffices — no expression, no null risk","Never cache expressions in nullable fields without re-validating","Keep helper wrappers sealed so callers cannot pass null through"],"tags":["argumentnullexception","expression","mvvm","prism"],"backgroundTag":"null-argument","analyzedSha":"358118cd640d9a22ff8cf21c8ad197fa038b7990","analyzedAt":"2026-09-15T15:00:31.079Z","contentChangedAt":"2026-09-15T15:00:31.079Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}