{"record":{"id":"9ff3438e9524d547","repo":"unoplatform/uno","slug":"unable-to-find-methodname-property-on-symbol","errorCode":null,"errorMessage":"Unable to find 'MethodName' property on '{symbol}'","messagePattern":"Unable to find 'MethodName' property on '(.+?)'","errorType":"exception","errorClass":"XamlGenerationException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs","lineNumber":2274,"sourceCode":"\t\t}\n\n\t\tprivate bool IsCustomMarkupExtensionType(XamlType? xamlType, bool allowExtensionSuffix = true) =>\n\t\t\t// Determine if the type is a custom markup extension\n\t\t\tGetMarkupExtensionType(xamlType, allowExtensionSuffix) != null;\n\n\t\tprivate bool IsXamlTypeConverter(INamedTypeSymbol? symbol)\n\t\t{\n\t\t\treturn symbol?.GetAttributes().Any(a => a.AttributeClass?.Equals(Generation.CreateFromStringAttributeSymbol.Value, SymbolEqualityComparer.Default) == true) == true;\n\t\t}\n\n\t\tprivate string BuildXamlTypeConverterLiteralValue(INamedTypeSymbol? symbol, string memberValue, bool includeQuotations, IXamlLocation location)\n\t\t{\n\t\t\tvar attributeData = symbol.FindAttribute(Generation.CreateFromStringAttributeSymbol.Value);\n\t\t\tvar targetMethod = attributeData?.NamedArguments.FirstOrDefault(kvp => kvp.Key == \"MethodName\").Value.Value?.ToString();\n\n\t\t\tif (targetMethod == null)\n\t\t\t{\n\t\t\t\tthrow new XamlGenerationException($\"Unable to find 'MethodName' property on '{symbol}'\", location);\n\t\t\t}\n\n\t\t\t// Since the MethodName value can simply be the name of the method\n\t\t\t// without its full path, example: nameof(MyConversionMethod), we must\n\t\t\t// make sure to fully qualify the method name with its namespace\n\t\t\tvar fullyQualifiedOwnerType = !targetMethod.Contains('.')\n\t\t\t\t? $\"{symbol?.GetFullyQualifiedTypeIncludingGlobal()}.{targetMethod}\"\n\t\t\t\t: GetGlobalizedTypeName(targetMethod);\n\n\t\t\tvar literalValue = default(string);\n\t\t\tif (includeQuotations)\n\t\t\t{\n\t\t\t\t// Return a string that contains the code which calls the \"conversion\" function with the member value\n\t\t\t\tliteralValue = \"{0}(\\\"{1}\\\")\".InvariantCultureFormat(fullyQualifiedOwnerType, memberValue);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t// Return a string that contains the code which calls the \"conversion\" function with the member value.","sourceCodeStart":2256,"sourceCodeEnd":2292,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs#L2256-L2292","documentation":"Thrown by BuildXamlTypeConverterLiteralValue when a type decorated with [CreateFromString] does not have a 'MethodName' named argument on the attribute. The generator reads the MethodName named argument to find the conversion method; if it is absent or null, this XamlGenerationException fires.","triggerScenarios":"A type is decorated with [CreateFromString] but the MethodName property of the attribute is not set, or the attribute instance is malformed — e.g. [CreateFromString] with no arguments, or with other named arguments but not MethodName.","commonSituations":"A custom XAML type converter type was decorated with [CreateFromString] incompletely; the attribute was copied from an example without filling in MethodName; the attribute definition changed and MethodName is no longer defaulted.","solutions":["Add MethodName to the [CreateFromString] attribute, pointing to the static method that performs string-to-type conversion.","Ensure the method name is correct and the method exists as a public static method on the type.","Follow the existing pattern from other [CreateFromString]-decorated types in the codebase."],"exampleFix":"// before\n[CreateFromString]\npublic class MyType { ... }\n// after\n[CreateFromString(MethodName = nameof(Parse))]\npublic class MyType\n{\n    public static MyType Parse(string value) { ... }\n}","handlingStrategy":"validation","validationCode":"// Verify [CreateFromString] has MethodName before using the type in XAML:\n// var attr = typeof(MyType).GetCustomAttribute<CreateFromStringAttribute>();\n// if (attr == null || string.IsNullOrEmpty(attr.MethodName))\n//     Console.WriteLine(\"[CreateFromString] must specify MethodName\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set MethodName when decorating a type with [CreateFromString].","Ensure the named method is public, static, and takes a single string parameter.","Copy the full attribute pattern from existing type-converter types in the codebase."],"tags":["type-converter","xaml","source-generator","createfromstring","attribute"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}