{"record":{"id":"d86a18a953af9bd9","repo":"dotnet/wpf","slug":"cannot-convert-from-type-fonttypeconverter","errorCode":null,"errorMessage":"Cannot convert from type.","messagePattern":"Cannot convert from type\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/FontTypeConverter.cs","lineNumber":106,"sourceCode":"        /// <param name=\"value\">\n        /// The Object to convert.\n        /// </param>\n        /// <returns>\n        /// An Object that represents the converted value.\n        /// </returns>\n        public\n        override\n        object\n        ConvertFrom(\n            ITypeDescriptorContext              context,\n            System.Globalization.CultureInfo    culture,\n            object                              value\n            )\n        {\n            ArgumentNullException.ThrowIfNull(value);\n            if (!IsSupportedType(value.GetType()))\n            {\n                throw new NotSupportedException(SR.Converter_ConvertFromNotSupported);\n            }\n\n            throw new NotImplementedException();\n        }\n\n        /// <summary>\n        /// Converts the given value object to the specified type,\n        /// using the arguments.\n        /// </summary>\n        /// <param name=\"context\">\n        /// An ITypeDescriptorContext that provides a format context.\n        /// </param>\n        /// <param name=\"culture\">\n        /// A CultureInfo object. If null is passed, the current\n        /// culture is assumed.\n        /// </param>\n        /// <param name=\"value\">\n        /// The Object to convert.","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/FontTypeConverter.cs#L88-L124","documentation":"FontTypeConverter.ConvertFrom rejects null (ArgumentNullException), unsupported value types (NotSupportedException 'Cannot convert from type.'), and finally throws NotImplementedException for supported types - conversion 'from' is deliberately not implemented for font serialization.","triggerScenarios":"Calling ConvertFrom on FontTypeConverter: null value, a value whose type fails IsSupportedType (e.g. a Color), or any supported-typed value (always throws).","commonSituations":"Tests and serialization pipelines probing the converter; XAML systems expecting standard TypeConverter behavior for fonts.","solutions":["Do not use FontTypeConverter to build FontFamily/GlyphRun objects; construct them directly.","Ensure only the converter's supported value types are passed.","Catch NotSupportedException/NotImplementedException at the converter boundary.","Register a custom converter implementing ConvertFrom if needed."],"exampleFix":"// before\nvar font = converter.ConvertFrom(context, culture, fontFamilyString);\n// after\nvar font = new FontFamily(fontFamilyString);","handlingStrategy":"type-guard","validationCode":"if (value == null) throw new ArgumentNullException(nameof(value));\nif (value is not Color) throw new NotSupportedException(\"unsupported source type\");","typeGuard":"static bool CanConvertFrom(object v) => v != null; // ConvertFrom still throws NotImplementedException","tryCatchPattern":"try { return converter.ConvertFrom(context, culture, value); }\ncatch (Exception ex) when (ex is ArgumentNullException or NotSupportedException or NotImplementedException) { /* fallback construction */ }","preventionTips":["Never use FontTypeConverter.ConvertFrom; construct font objects directly.","Pass non-null, supported-typed values if you must call it.","Treat ReachFramework converters as serialization-internal APIs."],"tags":["wpf","type-converter","not-implemented"],"backgroundTag":"method-not-implemented","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}