{"record":{"id":"6aee9db94137aea0","repo":"dotnet/wpf","slug":"sr-unknownindextype","errorCode":null,"errorMessage":"SR.UnknownIndexType","messagePattern":"SR\\.UnknownIndexType","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XamlInt32CollectionSerializer.cs","lineNumber":324,"sourceCode":"                        {                    \n                            theCollection.Add( (int) reader.ReadUInt16()); \n                        }\n                    }\n                    break; \n                        \n                    case IntegerCollectionType.Integer : \n                    {                    \n                        for ( int i = 0; i < count; i++ ) \n                        {                    \n                            int value = reader.ReadInt32(); \n\n                            theCollection.Add( value);\n                        }                            \n                    }                            \n                    break; \n                    \n                    default:\n                        throw new ArgumentException(SR.UnknownIndexType); \n                }\n            }\n\n            return theCollection; \n        }\n#endif\n\n#endregion Conversions\n\n        internal enum IntegerCollectionType : byte\n        {\n            Unknown = 0,\n            Consecutive = 1,\n            Byte = 2, \n            UShort= 3, \n            Integer=  4\n        }\n    }","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XamlInt32CollectionSerializer.cs#L306-L342","documentation":"The IntegerCollection BAML record encodes an IntegerCollectionType describing how values follow the count in the stream. DeserializeFrom switches on that type; an unrecognized type value means the binary payload does not conform to the known format, so ArgumentException(SR.UnknownIndexType) is thrown. This code path is compiled only under PBTCOMPILER.","triggerScenarios":"ConvertCustomBinaryToObject / StaticConvertCustomBinaryToObject encounters an IntegerCollection whose IntegerCollectionType byte is not one of the supported enum values (e.g. data produced by a newer/older compiler).","commonSituations":"Cross-version BAML incompatibility, hand-modified compiled resources, fuzzed or adversarial binary input to a XAML deserializer.","solutions":["Recompile the XAML/BAML with the same WPF version the runtime uses.","Inspect the binary payload's type byte and confirm it is a supported IntegerCollectionType.","If handling untrusted input, pre-validate the type byte before deserialization and reject unknown values."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"byte typeByte = data[4]; // after Int32 count\nif (!Enum.IsDefined(typeof(IntegerCollectionType), typeByte))\n    throw new InvalidDataException($\"Unknown IntegerCollectionType {typeByte}\");","typeGuard":null,"tryCatchPattern":"try { obj = serializer.ConvertCustomBinaryToObject(data); }\ncatch (ArgumentException ex) { LogCorruptBaml(ex); return null; }","preventionTips":["Compile and consume BAML with the same WPF/framework version.","Treat untrusted binary XAML as untrusted input and pre-validate type bytes."],"tags":["wpf","baml","deserialization","invalid-enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}