{"record":{"id":"042ed6e6f02a0a77","repo":"dotnet/wpf","slug":"sr-format-sr-pathparameterisnull-index","errorCode":null,"errorMessage":"SR.Format(SR.PathParameterIsNull, index)","messagePattern":"SR\\.Format\\(SR\\.PathParameterIsNull, index\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/PropertyPath.cs","lineNumber":726,"sourceCode":"                    // no value string \"(2)\" - value comes from PathParameter list\n                    int index;\n                    if (Int32.TryParse( paramList[i].parenString.Trim(),\n                                        NumberStyles.Integer,\n                                        TypeConverterHelper.InvariantEnglishUS.NumberFormat,\n                                        out index))\n                    {\n                        if (0 <= index && index < PathParameters.Count)\n                        {\n                            object value = PathParameters[index];\n                            if (value != null)\n                            {\n                                args[i].value = value;\n                                args[i].type = value.GetType();\n                            }\n                            else if (throwOnError)\n                            {\n                                // info.value will still be \"(n)\"\n                                throw new InvalidOperationException(SR.Format(SR.PathParameterIsNull, index));\n                            }\n                        }\n                        else if (throwOnError)\n                            throw new InvalidOperationException(SR.Format(SR.PathParametersIndexOutOfRange, index, PathParameters.Count));\n                    }\n                    else\n                    {\n                        // parens didn't hold an integer \"(abc)\" - value is (uninterpreted) paren string\n                        // [this could be considered an error, but the original code\n                        // treated it like this, so to preserve compatibility...]\n                        args[i].value = $\"({paramList[i].parenString})\";\n                    }\n                }\n                else\n                {\n                    // both strings appear \"(Double)3.14159\" - value is type-converted from value string\n                    args[i].type = GetTypeFromName(paramList[i].parenString, context);\n                    if (args[i].type != null)","sourceCodeStart":708,"sourceCodeEnd":744,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/PropertyPath.cs#L708-L744","documentation":"ResolveIndexerParams throws this InvalidOperationException when an indexer parameter '(n)' in the path resolves to a valid index but PathParameters[n-1] is null. The parameter value is required to build the indexer arguments, and a null entry means the indexer argument cannot be produced.","triggerScenarios":"Path string with '(1)' or '(2)' indexer references where the corresponding entry in the PathParameters collection was explicitly set to null; forgetting to initialize an accessor slot before constructing the PropertyPath.","commonSituations":"Building indexer paths like '[(0)]' for multi-binding indexers where one accessor slot is left null; conditional code paths that populate some but not all PathParameters entries; deserialization producing null accessor entries.","solutions":["Ensure every index referenced as '(n)' in the path has a non-null accessor in PathParameters[n-1]","Remove the '(n)' reference from the path string if no parameter is intended","Pre-validate the PathParameters collection for null entries before constructing/resolving the path","Pass literal indexer values in the path string (e.g. '[3]') instead of parameter references"],"exampleFix":"// before\npath.PathParameters.Add(null); // slot for '(1)'\n// after\npath.PathParameters.Add(typeof(C).GetProperty(\"Item\")); // non-null accessor","handlingStrategy":"validation","validationCode":"bool noNulls = path.PathParameters.Cast<object>().All(p => p != null);","typeGuard":"bool AllParamsNonNull(System.Collections.IEnumerable ps) => ps.Cast<object>().All(p => p != null);","tryCatchPattern":"try { path.ResolveIndexerParams(list, item, context, throwOnError: true); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"null\")) { /* fill the missing parameter */ }","preventionTips":["Initialize every PathParameters slot before constructing indexed paths","Avoid conditional population of PathParameters; populate all-or-nothing","Assert non-null parameters in tests for indexer-style paths"],"tags":["wpf","binding","property-path","indexer","null-argument"],"backgroundTag":"null-argument","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"}