{"record":{"id":"2f42a34feaaf352a","repo":"PrismLibrary/Prism","slug":"expression","errorCode":null,"errorMessage":"expression","messagePattern":"expression","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Prism.Core/Mvvm/PropertySupport.cs","lineNumber":46,"sourceCode":"                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));\n\n            var memberExpression = expression.Body as MemberExpression;\n            if (memberExpression == null)\n                throw new ArgumentException(Resources.PropertySupport_NotMemberAccessExpression_Exception, nameof(expression));\n\n            var property = memberExpression.Member as PropertyInfo;\n            if (property == null)\n                throw new ArgumentException(Resources.PropertySupport_ExpressionNotProperty_Exception, nameof(expression));\n\n            var getMethod = property.GetMethod;\n            if (getMethod.IsStatic)\n                throw new ArgumentException(Resources.PropertySupport_StaticExpression_Exception, nameof(expression));\n\n            return memberExpression.Member.Name;\n        }\n\n    }\n}","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Prism.Core/Mvvm/PropertySupport.cs#L28-L64","documentation":"The internal helper ExtractPropertyNameFromLambda throws ArgumentNullException when the 'expression' LambdaExpression is null. It is called by ExtractPropertyName after the public null check, so it acts as a second line of defense for direct internal callers.","triggerScenarios":"Internally passing a null LambdaExpression to ExtractPropertyNameFromLambda; race conditions where a shared expression variable is set to null between the public check and the internal call.","commonSituations":"Custom property-name utilities copied from Prism source; generic reflection helpers that resolve expressions at runtime and may yield null.","solutions":["Ensure any LambdaExpression passed is non-null before the call","Only use the public ExtractPropertyName<T> API, which performs its own null check","Validate the upstream source of the expression (e.g. delegate resolution) can return null"],"exampleFix":"// before\nPropertySupport.ExtractPropertyNameFromLambda(null);\n// after\nif (lambda != null)\n    PropertySupport.ExtractPropertyNameFromLambda(lambda);","handlingStrategy":"type-guard","validationCode":"if (lambda == null)\n    throw new ArgumentException(\"Lambda expression required\");","typeGuard":"bool IsNonNullLambda(LambdaExpression? e) => e is not null;","tryCatchPattern":"try\n{\n    var name = ExtractPropertyNameFromLambda(lambda);\n}\ncatch (ArgumentNullException ex)\n{\n    logger.LogError(ex, \"Null lambda passed to property-name extractor\");\n}","preventionTips":["Call the public ExtractPropertyName<T> API rather than the internal helper","Validate delegate/expression resolution results before use","Avoid storing LambdaExpressions in mutable shared state"],"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"}