{"record":{"id":"a28a4a29c899aaf8","repo":"dotnet/wpf","slug":"sr-malformedpropertyname","errorCode":null,"errorMessage":"SR.MalformedPropertyName","messagePattern":"SR\\.MalformedPropertyName","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/MeScanner.cs","lineNumber":319,"sourceCode":"            if (xamlType is null ||\n                // Guard against Extension getting added twice\n                (xamlType.UnderlyingType is not null &&\n                 KS.Eq(xamlType.UnderlyingType.Name, typeName.Name + KnownStrings.Extension)))\n            {\n                typeName.Name = bareTypeName;\n                xamlType = _context.GetXamlType(typeName, true);\n            }\n\n            _tokenXamlType = xamlType;\n            _tokenNamespace = typeName.Namespace;\n        }\n\n        private void ResolvePropertyName(string longName)\n        {\n            XamlPropertyName propName = XamlPropertyName.Parse(longName);\n            if (propName is null)\n            {\n                throw new ArgumentException(SR.MalformedPropertyName);\n            }\n\n            XamlMember prop = null;\n            XamlType declaringType;\n            XamlType tagType = _context.CurrentType;\n            string tagNamespace = _context.CurrentTypeNamespace;\n\n            if (propName.IsDotted)\n            {\n                prop = _context.GetDottedProperty(tagType, tagNamespace, propName, tagIsRoot: false);\n            }\n\n            // Regular property p\n            else\n            {\n                string ns = _context.GetAttributeNamespace(propName, Namespace);\n                declaringType = _context.CurrentType;\n                prop = _context.GetNoDotAttributeProperty(declaringType, propName, Namespace, ns, tagIsRoot: false);","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/MeScanner.cs#L301-L337","documentation":"MeScanner.ResolvePropertyName throws ArgumentException with SR.MalformedPropertyName when XamlPropertyName.Parse cannot decompose a markup-extension property name (the text between a markup extension's member references, e.g. `{x:Static Member=...}` long names) into a valid namespace/type/member form. System.Xaml uses this scanner when parsing values like `{StaticResource Key}`; a name that does not match the grammar `ns:Type.Member` or `Type.Member` is rejected. It is thrown during scanner Read, which the XAML pull parser drives, so it surfaces as an exception during XamlReader.Load/XamlXmlReader parse.","triggerScenarios":"Calling XamlReader.Load / XamlXmlReader on XAML containing a markup extension whose property longName (the string before '=' inside the extension braces) does not parse — e.g. `{StaticResource =Value}` (empty name), `{StaticResource a..b=Value}`, or an unbalanced dotted name inside a markup extension property assignment.","commonSituations":"Hand-edited or tool-generated XAML with a typo in a markup-extension property name; string-interpolated XAML where an empty or malformed property name is emitted; WPF/.NET Core migration where previously silently-tolerated syntax is now strictly scanned.","solutions":["Fix the markup-extension property name in the XAML so it matches ns:Type.Member or Type.Member grammar.","Ensure no leading/trailing '=' with an empty property name inside the braces.","If the value legitimately contains '=' or braces as literal text, escape the opening brace with {} (e.g. {}{literal}) or use x:Static/attribute syntax instead.","Re-run XamlReader.Load on a minimal snippet to isolate the offending element and line."],"exampleFix":"<!-- before -->\n<TextBlock Text=\"{StaticResource =HeaderKey}\" />\n\n<!-- after -->\n<TextBlock Text=\"{StaticResource HeaderKey}\" />","handlingStrategy":"try-catch","validationCode":"if (xaml.Contains(\"=\") && System.Text.RegularExpressions.Regex.IsMatch(xaml, @\"\\{[^}]*=\\s*[^\\w:.]\")) throw new FormatException(\"Suspicious markup-extension property assignment\");","typeGuard":null,"tryCatchPattern":"try { var obj = XamlReader.Parse(xaml); } catch (XamlParseException ex) { log(ex.Message, ex.LineNumber, ex.LinePosition); }","preventionTips":["Author markup extensions in an XAML-aware IDE with schema validation","Never build extension strings by raw string concatenation","Escape literal braces with {} prefix"],"tags":["xaml","markup-extension","parser","wpf"],"backgroundTag":"invalid-argument-format","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"}