{"record":{"id":"4086313cc425fcf4","repo":"HandyOrg/HandyControl","slug":"unexpectedparametertype","errorCode":null,"errorMessage":"UnexpectedParameterType","messagePattern":"UnexpectedParameterType","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Shared/HandyControl_Shared/Tools/Converter/ColLayoutConverter.cs","lineNumber":55,"sourceCode":"    {\n        if (source == null) throw GetConvertFromException(null);\n\n        return source switch\n        {\n            string s => FromString(s, cultureInfo),\n            double d => new ColLayout((int) d),\n            _ => new ColLayout(Convert.ToInt32(source, cultureInfo))\n        };\n    }\n\n    [SecurityCritical]\n    public override object ConvertTo(ITypeDescriptorContext typeDescriptorContext, CultureInfo cultureInfo, object value, Type destinationType)\n    {\n        if (value == null) throw new ArgumentNullException(nameof(value));\n\n        if (destinationType == null) throw new ArgumentNullException(nameof(destinationType));\n\n        if (!(value is ColLayout th)) throw new ArgumentException(\"UnexpectedParameterType\");\n\n        if (destinationType == typeof(string)) return ToString(th, cultureInfo);\n        if (destinationType == typeof(InstanceDescriptor))\n        {\n            var ci = typeof(ColLayout).GetConstructor(new[] { typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int) });\n            return new InstanceDescriptor(ci, new object[] { th.Xs, th.Sm, th.Md, th.Lg, th.Xl, th.Xxl });\n        }\n\n        throw new ArgumentException(\"CannotConvertType\");\n    }\n\n    private static string ToString(ColLayout th, CultureInfo cultureInfo)\n    {\n        var listSeparator = TokenizerHelper.GetNumericListSeparator(cultureInfo);\n\n        // Initial capacity [128] is an estimate based on a sum of:\n        // 72 = 6x double (twelve digits is generous for the range of values likely)\n        //  4 = 4x separator characters","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/HandyOrg/HandyControl/blob/2c0875ebd67326e0c67282967e3e809c69282fee/src/Shared/HandyControl_Shared/Tools/Converter/ColLayoutConverter.cs#L37-L73","documentation":"Type guard in ColLayoutConverter.ConvertTo: throws ArgumentException(\"UnexpectedParameterType\") when the value to convert is not a ColLayout instance. The converter only serializes ColLayout objects, so any other runtime type reaching ConvertTo triggers this sentinel error.","triggerScenarios":"Thrown at src/Shared/HandyControl_Shared/Tools/Converter/ColLayoutConverter.cs:55 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Only call ConvertTo with a ColLayout value","Pattern-match with 'value is ColLayout' and handle the negative case gracefully (return base conversion) instead of throwing","Validate the source type at the binding/designer call site"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2c0875ebd67326e0c67282967e3e809c69282fee","analyzedAt":"2026-09-14T14:45:29.754Z","contentChangedAt":"2026-09-14T14:45:29.754Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}