{"record":{"id":"88bc0c829fac8943","repo":"stride3d/stride","slug":"value-cannot-be-null-parameter-name","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'name')","messagePattern":"Value cannot be null\\. \\(Parameter 'name'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.UI/DependencyPropertyFactory.cs","lineNumber":134,"sourceCode":"        public static PropertyKey<T> RegisterAttached<T>(string name, Type ownerType, T defaultValue, ObjectInvalidationCallback<T> invalidationCallback)\n        {\n            return RegisterAttached(name, ownerType, defaultValue, null, invalidationCallback);\n        }\n\n        /// <summary>\n        /// Registers an attached dependency property.\n        /// </summary>\n        /// <typeparam name=\"T\">The type of the property.</typeparam>\n        /// <param name=\"name\">The name of the property.</param>\n        /// <param name=\"ownerType\">The type that is registering the property.</param>\n        /// <param name=\"defaultValue\">The default value of the property.</param>\n        /// <param name=\"validateValueCallback\">A callback for validation/coercision of the property's value.</param>\n        /// <param name=\"invalidationCallback\">A callback to invalidate an object state after a modification of the property's value.</param>\n        /// <param name=\"metadatas\">The metadatas.</param>\n        /// <returns></returns>\n        public static PropertyKey<T> RegisterAttached<T>(string name, Type ownerType, T defaultValue, ValidateValueCallback<T> validateValueCallback, ObjectInvalidationCallback<T> invalidationCallback, params PropertyKeyMetadata[] metadatas)\n        {\n            if (name == null) throw new ArgumentNullException(nameof(name));\n            if (ownerType == null) throw new ArgumentNullException(nameof(ownerType));\n            if (metadatas == null) throw new ArgumentNullException(nameof(metadatas));\n\n            return RegisterCommon(DependencyPropertyKeyMetadata.Attached, name, ownerType, defaultValue, validateValueCallback, invalidationCallback, metadatas);\n        }\n\n        // ReSharper disable once SuggestBaseTypeForParameter\n        private static PropertyKey<T> RegisterCommon<T>(DependencyPropertyKeyMetadata dependencyPropertyMetadata, string name, Type ownerType, T defaultValue, ValidateValueCallback<T> validateValueCallback, ObjectInvalidationCallback<T> invalidationCallback, params PropertyKeyMetadata[] otherMetadatas)\n        {\n            var metadataList = new List<PropertyKeyMetadata> { dependencyPropertyMetadata, DefaultValueMetadata.Static(defaultValue) };\n            if (validateValueCallback != null)\n                metadataList.Add(ValidateValueMetadata.New(validateValueCallback));\n            if (invalidationCallback != null)\n                metadataList.Add(ObjectInvalidationMetadata.New(invalidationCallback));\n            metadataList.AddRange(otherMetadatas);\n\n            return new PropertyKey<T>(name, ownerType, metadataList.ToArray());\n        }","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.UI/DependencyPropertyFactory.cs#L116-L152","documentation":"RegisterAttached registers an attached dependency property, which must be scoped to a name and owner type. A null name leaves the property unidentifiable, so the factory throws ArgumentNullException(nameof(name)) as its first validation.","triggerScenarios":"Calling DependencyPropertyFactory.RegisterAttached<T>(null, ownerType, ...) with a null/empty property name, e.g. from a config-driven or reflection-based registration where the name lookup failed.","commonSituations":"Dynamic registration systems that read property names from configuration or attributes; code generation with a missing name constant; refactoring where the name literal was accidentally deleted.","solutions":["Pass a non-null property name string to RegisterAttached","Validate names loaded from config/reflection before calling the factory","Fail fast earlier with a clear message if a name cannot be resolved"],"exampleFix":"// before\nvar key = DependencyPropertyFactory.RegisterAttached<string>(null, typeof(Grid), default); // throws\n// after\nvar key = DependencyPropertyFactory.RegisterAttached<string>(\"MyAttachedProp\", typeof(Grid), default);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(name))\n    throw new ArgumentException(\"Attached property name is required\");","typeGuard":"bool CanRegisterAttached(string name, Type ownerType) => !string.IsNullOrEmpty(name) && ownerType != null;","tryCatchPattern":"try\n{\n    key = DependencyPropertyFactory.RegisterAttached<T>(name, ownerType, default);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"name\")\n{\n    // fix the name source before retrying\n}","preventionTips":["Validate config/attribute-derived names before registration","Use const strings for property names","Fail fast with a descriptive message when a name cannot be resolved"],"tags":["dependency-property","null-argument","attached-property"],"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"}