{"record":{"id":"220fc4c3b86bbb3c","repo":"AvaloniaUI/Avalonia","slug":"invalid-format-function-expects-count-value-s","errorCode":null,"errorMessage":"Invalid format. {function} expects {count} value(s).","messagePattern":"Invalid format\\. (.+?) expects (.+?) value\\(s\\)\\.","errorType":"validation","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Media/Transformation/TransformParser.cs","lineNumber":361,"sourceCode":"                case Unit.Turn:\n                {\n                    return true;\n                }\n            }\n\n            return false;\n        }\n\n        private static void ThrowFormatInvalidValue(TransformFunction function, in UnitValue value)\n        {\n            var unitString = value.Unit == Unit.None ? string.Empty : value.Unit.ToString();\n\n            throw new FormatException($\"Invalid value {value.Value} {unitString} for {function}\");\n        }\n\n        private static void ThrowFormatInvalidValueCount(TransformFunction function, int count)\n        {\n            throw new FormatException($\"Invalid format. {function} expects {count} value(s).\");\n        }\n\n        private static Unit ParseUnit(in ReadOnlySpan<char> part)\n        {\n            foreach (var (name, unit) in s_unitMapping)\n            {\n                if (part.Equals(name.AsSpan(), StringComparison.OrdinalIgnoreCase))\n                {\n                    return unit;\n                }\n            }\n\n            throw new FormatException($\"Invalid unit: {part.ToString()}\");\n        }\n\n        private static TransformFunction ParseTransformFunction(in ReadOnlySpan<char> part)\n        {\n            foreach (var (name, transformFunction) in s_functionMapping)","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Media/Transformation/TransformParser.cs#L343-L379","documentation":"Thrown by TransformParser.ThrowFormatInvalidValueCount when a transform function is given the wrong number of arguments. The message states the exact count the function expects, e.g. 'Invalid format. scale expects 2 value(s).' This is a count mismatch, distinct from error 325 (too many) which is the raw overflow guard; this is the function-level expectation.","triggerScenarios":"Calling a transform function with fewer arguments than required, e.g. scale(2) where two are needed (depending on function definition), or matrix() with the wrong arity. The function's declared count is checked after parsing and ThrowFormatInvalidValueCount is invoked on mismatch.","commonSituations":"Hand-authored transforms missing arguments; copy-paste truncation; assuming a single-argument shorthand that the parser does not accept.","solutions":["Supply exactly the number of values the message reports the function expects.","Look up the function's required arity in the transform documentation.","If a single-value shorthand is desired, verify the parser supports it; otherwise provide the full argument list."],"exampleFix":"// before\nvar t = TransformOperations.Parse(\"translate(10px)\"); // if translate expects 2 values\n\n// after\nvar t = TransformOperations.Parse(\"translate(10px, 0px)\");","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { return TransformOperations.Parse(s); }\ncatch (FormatException ex) when (ex.Message.Contains(\"expects\"))\n{ /* supply the exact value count from the message */ }","preventionTips":["Provide exactly the number of arguments the function requires.","Read the expected count from the exception message when debugging.","Avoid relying on single-argument shorthands unless documented as supported."],"tags":["transform","parse","format-exception","argument-count","avalonia"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}