{"record":{"id":"1f538a107ac0a55e","repo":"dotnet/wpf","slug":"args-rowcache","errorCode":null,"errorMessage":"args","messagePattern":"args","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/documents/RowCache.cs","lineNumber":1276,"sourceCode":"                            }\n\n                            //If because of the above trimming we have fewer pages left \n                            //in the document than the columns that were initially requested\n                            //We'll need to recalc our layout from scratch.\n                            //First we check to see if we have one or fewer rows left.\n                            if (_rowCache.Count <= 1)\n                            {\n                                //If we have either no rows left or the remaining row has\n                                //less than _layoutColumns pages on it, we need to recalc from the first page.\n                                if (_rowCache.Count == 0 || _rowCache[0].PageCount < _layoutColumns)\n                                {\n                                    RecalcRows(0, _layoutColumns);\n                                }\n                            }\n                            break;\n\n                        default:\n                            throw new ArgumentOutOfRangeException(nameof(args));\n                    }\n                }\n\n                RowCacheChangedEventArgs newArgs = new RowCacheChangedEventArgs(changes);\n                RowCacheChanged(this, newArgs);\n            }\n            else if (_isLayoutRequested)\n            {\n                //We've had a request to create a layout previously, but didn't have enough pages to do so before.\n                //Try it now.\n                RecalcRows(_layoutPivotPage, _layoutColumns);\n            }\n        }\n\n        /// <summary>\n        /// Handler for the OnPaginationCompleted event.  If we still have an unfulfilled\n        /// layout request, we'll call RecalcRows to ensure that we get a layout (though possibly\n        /// with fewer columns than requested.)","sourceCodeStart":1258,"sourceCodeEnd":1294,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/documents/RowCache.cs#L1258-L1294","documentation":"The RowCache change-processing switch handles a fixed set of RowCacheChangeTypes; any unrecognized type falls into the default case, which throws ArgumentOutOfRangeException(nameof(args)). This signals an unknown or future change type reaching the cache's handler.","triggerScenarios":"Passing a RowCacheChangedEventArgs whose change type is not one of the values handled by the switch (e.g. an invalid enum value, a type added by a newer version, or a wrongly-constructed change) into the RowCache change handler.","commonSituations":"Custom code constructing RowCacheChangedEventArgs with an uninitialized/default or out-of-range change type enum; version mismatch where a new RowCacheChangeType flows into older handler logic; wiring the wrong event args into the handler.","solutions":["Check the RowCacheChangeType value being produced — ensure it is a valid, defined enum member","Initialize change-type fields explicitly instead of relying on default(enum)","Verify assembly versions match so enum values are consistent between producer and consumer","Extend the switch to handle any new change types if using a modified build"],"exampleFix":"// before\nvar args = new RowCacheChangedEventArgs(changes);\n// after\nif (!Enum.IsDefined(typeof(RowCacheChangeType), changeType))\n{\n    throw new ArgumentOutOfRangeException(nameof(changeType));\n}\nvar args = new RowCacheChangedEventArgs(changes);","handlingStrategy":"validation","validationCode":"if (!Enum.IsDefined(typeof(RowCacheChangeType), changeType)) throw new ArgumentOutOfRangeException(nameof(changeType));","typeGuard":"bool IsValidChangeType(RowCacheChangeType t) => Enum.IsDefined(typeof(RowCacheChangeType), t);","tryCatchPattern":"try { cache.ProcessChange(args); } catch (ArgumentOutOfRangeException) { logUnknownChangeType(args); }","preventionTips":["Always initialize change-type enum fields explicitly","Keep producer and consumer assemblies on matching versions so enum values agree"],"tags":["wpf","documents","argument-out-of-range","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-22T01:17:13.364Z"}