{"record":{"id":"f06c780dce053054","repo":"stride3d/stride","slug":"value-cannot-be-null-parameter-property-f06c78","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'property')","messagePattern":"Value cannot be null\\. \\(Parameter 'property'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Wpf/Extensions/DependencyObjectExtensions.cs","lineNumber":50,"sourceCode":"                flags |= BindingFlags.FlattenHierarchy;\n\n            return source.DependencyObjectType.SystemType.GetFields(flags)\n                .Where(fi => fi.MemberType == MemberTypes.Field && fi.FieldType == dependencyPropertyType)\n                .Select(fi => (DependencyProperty)fi.GetValue(source))\n                .OrderBy(dp => dp.Name)\n                .ToArray();\n        }\n\n        /// <summary>\n        /// Sets the value of a DependencyProperty on a DependencyObject and all its logical children.\n        /// </summary>\n        /// <param name=\"source\">Root DependencyObject of which to set the DependencyProperty value.</param>\n        /// <param name=\"property\">DependencyProperty to set.</param>\n        /// <param name=\"value\">Value to set.</param>\n        public static void DeepSetValue([NotNull] this DependencyObject source, [NotNull] DependencyProperty property, object value)\n        {\n            if (source == null) throw new ArgumentNullException(nameof(source));\n            if (property == null) throw new ArgumentNullException(nameof(property));\n\n            source.SetValue(property, value);\n            foreach (object child in LogicalTreeHelper.GetChildren(source as dynamic))\n            {\n                var depChild = child as DependencyObject;\n                depChild?.DeepSetValue(property, value);\n            }\n        }\n\n        /// <summary>\n        /// Find the root parent, along the visual tree.\n        /// </summary>\n        /// <param name=\"source\">Base node from where to start looking for root.</param>\n        /// <returns>Returns the retrieved root, or null otherwise.</returns>\n        [CanBeNull]\n        public static Visual FindVisualRoot([NotNull] this DependencyObject source)\n        {\n            if (source == null) throw new ArgumentNullException(nameof(source));","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/Extensions/DependencyObjectExtensions.cs#L32-L68","documentation":"DeepSetValue requires both a source DependencyObject and a DependencyProperty to set. It validates the property is non-null and throws ArgumentNullException with parameter name 'property', since DependencyProperty.SetValue would fail without a valid property identifier.","triggerScenarios":"Calling DeepSetValue with a null DependencyProperty, e.g. a static field lookup (Control.FontSizeProperty) that was misnamed or the property was resolved dynamically and returned null.","commonSituations":"Reflection lookup of a *Property field returning null; copy-paste from a different control type; refactoring renamed the property field.","solutions":["Pass the correct static DependencyProperty field (e.g. TextBlock.TextProperty).","Null-check the resolved property before calling DeepSetValue.","Verify the property exists on the target control type before reflection-resolving it."],"exampleFix":"// before\nvar prop = typeof(TextBlock).GetField(\"TextProp\")?.GetValue(null) as DependencyProperty; // null\nroot.DeepSetValue(prop, value);\n// after\nvar prop = typeof(TextBlock).GetField(\"TextProperty\")?.GetValue(null) as DependencyProperty;\nif (prop != null)\n    root.DeepSetValue(prop, value);","handlingStrategy":"type-guard","validationCode":"if (prop == null) throw new InvalidOperationException(\"DependencyProperty must be resolved before DeepSetValue\");","typeGuard":"bool CanDeepSet(DependencyObject source, DependencyProperty prop) => source != null && prop != null;","tryCatchPattern":"try { root.DeepSetValue(prop, value); } catch (ArgumentNullException ex) when (ex.ParamName == \"property\") { /* resolve property by name, log */ }","preventionTips":["Reference static *Property fields directly instead of reflection lookups","Null-check reflection-resolved DependencyProperty fields","Compile-time references survive refactoring; avoid string-based lookups"],"tags":["csharp","wpf","argument-null"],"backgroundTag":"null-argument","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}