{"record":{"id":"c45709089fedd0d4","repo":"dotnet/wpf","slug":"throw-new-argumentnullexception-nameof-list","errorCode":null,"errorMessage":"throw new ArgumentNullException(nameof(list));","messagePattern":"throw new ArgumentNullException\\(nameof\\(list\\)\\);","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/Shared/MS/Utility/FrugalMap.cs","lineNumber":1780,"sourceCode":"                _mapStore.GetKeyValuePair(index, out key, out value);\n            }\n            else\n            {\n                throw new ArgumentOutOfRangeException(nameof(index));\n            }\n        }\n        \n        public void Iterate(ArrayList list, FrugalMapIterationCallback callback)\n        {\n            if (null != callback)\n            {\n                if (null != list)\n                {\n                    _mapStore?.Iterate(list, callback);\n                }\n                else\n                {\n                    throw new ArgumentNullException(nameof(list));\n                }\n            }\n            else\n            {\n                throw new ArgumentNullException(nameof(callback));\n            }\n        }\n\n        public int Count\n        {\n            get\n            {\n                if (null != _mapStore)\n                {\n                    return _mapStore.Count;\n                }\n                return 0;\n            }","sourceCodeStart":1762,"sourceCodeEnd":1798,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/Shared/MS/Utility/FrugalMap.cs#L1762-L1798","documentation":"FrugalMap.Iterate validates its arguments and throws ArgumentNullException when the list parameter is null (and separately when callback is null), since both are required to collect the iterated entries.","triggerScenarios":"Calling FrugalMap.Iterate(null, callback) — the destination ArrayList is mandatory even if you only care about side effects of the callback.","commonSituations":"Utility wrappers that forward an uninitialized collection; refactoring where the list was made optional by the caller but remains required by the API.","solutions":["Always pass a non-null ArrayList instance to Iterate","Also ensure the callback delegate is non-null","Validate arguments at the wrapper boundary before delegating"],"exampleFix":"// before\nmap.Iterate(null, myCallback); // ArgumentNullException\n// after\nmap.Iterate(new ArrayList(), myCallback);","handlingStrategy":"validation","validationCode":"if (list == null) throw new ArgumentNullException(nameof(list));\nif (callback == null) throw new ArgumentNullException(nameof(callback));","typeGuard":"bool CanIterate(ArrayList list, FrugalMapIterationCallback cb) => list != null && cb != null;","tryCatchPattern":"try { map.Iterate(list, cb); } catch (ArgumentNullException ex) when (ex.ParamName is \"list\" or \"callback\") { /* supply required args and retry */ }","preventionTips":["Always allocate the destination ArrayList before Iterate","Pass a non-null delegate alongside it","Validate wrapper-function parameters before forwarding"],"tags":["wpf","frugalmap","argumentnullexception","iteration","api"],"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"}