{"record":{"id":"223dcce9ea7d2822","repo":"dotnet/wpf","slug":"argument-propertyname-cannot-be-null-or-empty","errorCode":null,"errorMessage":"Argument 'propertyName' cannot be null or empty.","messagePattern":"Argument 'propertyName' cannot be null or empty\\.","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsFormsIntegration/System/Windows/Integration/PropertyMap.cs","lineNumber":250,"sourceCode":"\n        /// <summary>\n        ///     Translator for individual property\n        /// </summary>\n        internal void EmptyPropertyTranslator(object host, string propertyName, object value)\n        {\n        }\n\n\n\n        /// <summary>\n        ///     Restores the default property mapping for the specified property.\n        /// </summary>\n        /// <param name=\"propertyName\">A string containing the name of the host control property.</param>\n        public void Reset(String propertyName)\n        {\n            if (string.IsNullOrEmpty(propertyName))\n            {\n                throw new ArgumentNullException(string.Format(CultureInfo.CurrentCulture, SR.WFI_ArgumentNullOrEmpty, \"propertyName\"));\n            }\n\n            //Resetting means get the value from the list of default values,\n            //if it's there, otherwise removing the item you've added.\n            PropertyTranslator value;\n            if (DefaultTranslators.TryGetValue(propertyName, out value))\n            {\n                this[propertyName] = value;\n            }\n            else\n            {\n                Remove(propertyName);\n            }\n        }\n\n        /// <summary>\n        ///     Restores the default property mapping for all of the host control's properties.\n        /// </summary>","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsFormsIntegration/System/Windows/Integration/PropertyMap.cs#L232-L268","documentation":"PropertyMap.Reset validates that the propertyName argument is a non-empty string before removing the custom translator and restoring the default one. A null or empty name cannot match any mapped property, so the method throws ArgumentNullException immediately.","triggerScenarios":"Calling propertyMap.Reset(null) or propertyMap.Reset(\"\") from code that clears translators dynamically, e.g. looping over a dictionary of overrides where the key was never initialized.","commonSituations":"Resetting all custom translations in a loop driven by a config or UI binding where a key is empty; calling Reset before any property name is assigned from deserialized configuration.","solutions":["Pass the exact non-empty property name, e.g. propertyMap.Reset(\"Background\").","Guard the call: if (!string.IsNullOrEmpty(name)) propertyMap.Reset(name);","Fix the source of the empty string (uninitialized variable, config key)."],"exampleFix":"// before\npropertyMap.Reset(propertyName); // propertyName may be \"\"\n// after\nif (!string.IsNullOrEmpty(propertyName))\n{\n    propertyMap.Reset(propertyName);\n}","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(propertyName))\n    return; // or throw your own descriptive error\npropertyMap.Reset(propertyName);","typeGuard":"bool IsValidPropertyName(string name) => !string.IsNullOrEmpty(name);","tryCatchPattern":"try { propertyMap.Reset(name); }\ncatch (ArgumentNullException ex) { log.Warn(\"Reset skipped: empty property name\", ex); }","preventionTips":["Initialize property-name variables before use","Validate config/UI-sourced names with string.IsNullOrEmpty before API calls","Prefer nameof(ControlType.Property) over dynamic strings"],"tags":["argument-null","validation","property-map"],"backgroundTag":"empty-required-field","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}