{"record":{"id":"9b84d4c96b5d7099","repo":"stride3d/stride","slug":"the-parameter-of-this-converter-must-be-an-instance-of-the-9b84d4","errorCode":null,"errorMessage":"The parameter of this converter must be an instance of the {nameof(XamlMarkdown)} class.","messagePattern":"The parameter of this converter must be an instance of the (.+?) class\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/TextToMarkdownFlowDocumentConverter.cs","lineNumber":18,"sourceCode":"// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)\n// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.\nusing System;\nusing System.Globalization;\nusing System.Windows.Data;\nusing System.Windows.Documents;\n\nnamespace Stride.Core.Presentation.ValueConverters\n{\n    [ValueConversion(typeof(string), typeof(FlowDocument))]\n    public class TextToMarkdownFlowDocumentConverter : OneWayValueConverter<TextToMarkdownFlowDocumentConverter>\n    {\n        /// <inheritdoc/>\n        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)\n        {\n            if (parameter != null && !(parameter is XamlMarkdown))\n            {\n                throw new ArgumentException($\"The parameter of this converter must be an instance of the {nameof(XamlMarkdown)} class.\");\n            }\n\n            if (value == null)\n                return null;\n\n            var engine = (XamlMarkdown)parameter ?? defaultMarkdown.Value;\n            if (engine == null)\n                return null;\n\n            try\n            {\n                var text = value.ToString();\n                return engine.Transform(text);\n            }\n            catch (ArgumentException) { }\n            catch (FormatException) { }\n            catch (InvalidOperationException) { }\n","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/TextToMarkdownFlowDocumentConverter.cs#L1-L36","documentation":"TextToMarkdownFlowDocumentConverter optionally accepts an XamlMarkdown engine as its converter parameter to control Markdown rendering. It throws this ArgumentException from Convert (TextToMarkdownFlowDocumentConverter.cs:18) only when parameter is non-null AND not an XamlMarkdown instance, because it later casts parameter to XamlMarkdown.","triggerScenarios":"Passing a non-XamlMarkdown, non-null ConverterParameter — e.g. a string, a boolean flag, or another IMarkdown engine implementation — into a binding using this converter.","commonSituations":"Developers passing configuration strings or flags via ConverterParameter out of habit; supplying a different Markdown engine type after a library refactor; copy-paste from converters that take string parameters.","solutions":["Remove the ConverterParameter entirely so the default XamlMarkdown engine is used (parameter == null is allowed).","Pass an actual `new XamlMarkdown()` (or a XamlMarkdown resource) as the parameter.","Configure a shared XamlMarkdown as a StaticResource and reference it via ConverterParameter=\"{StaticResource md}\".","Guard with `parameter is XamlMarkdown or null` before calling Convert."],"exampleFix":"// before\n<TextBlock ... ConverterParameter=\"github\" /> <!-- string, throws -->\n// after\n<md:XamlMarkdown x:Key=\"Engine\"/>\n<TextBlock ... ConverterParameter=\"{StaticResource Engine}\" />","handlingStrategy":"validation","validationCode":"bool ok = parameter == null || parameter is XamlMarkdown;","typeGuard":"static bool HasValidEngine(object p) => p is null or XamlMarkdown;","tryCatchPattern":"try { return converter.Convert(value, targetType, param, culture); }\ncatch (ArgumentException) { return null; }","preventionTips":["Omit ConverterParameter to use the built-in default XamlMarkdown engine.","Share a configured XamlMarkdown via StaticResource if custom rendering is needed.","Don't pass flags/strings as parameters to this converter — configuration goes on the XamlMarkdown instance."],"tags":["wpf","valueconverter","markdown","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}