{"record":{"id":"49cf65dc5cd3aee0","repo":"Unity-Technologies/UnityCsReference","slug":"list","errorCode":null,"errorMessage":"list","messagePattern":"list","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Animation/TickHandler.cs","lineNumber":153,"sourceCode":"            m_MinValue = minValue;\n            m_MaxValue = maxValue;\n            m_PixelRange = maxPixel - minPixel;\n        }\n\n        public float[] GetTicksAtLevel(int level, bool excludeTicksFromHigherlevels)\n        {\n            if (level < 0)\n                return Array.Empty<float>();\n\n            m_TickList.Clear();\n            GetTicksAtLevel(level, excludeTicksFromHigherlevels, m_TickList);\n            return m_TickList.ToArray();\n        }\n\n        public void GetTicksAtLevel(int level, bool excludeTicksFromHigherlevels, List<float> list)\n        {\n            if (list == null)\n                throw new System.ArgumentNullException(\"list\");\n\n            int l = Mathf.Clamp(m_SmallestTick + level, 0, m_TickModulos.Length - 1);\n            int startTick = Mathf.FloorToInt(m_MinValue / m_TickModulos[l]);\n            int endTick = Mathf.CeilToInt(m_MaxValue / m_TickModulos[l]);\n            for (int i = startTick; i <= endTick; i++)\n            {\n                // Return if tick mark is at same time as larger tick mark\n                if (excludeTicksFromHigherlevels\n                    && l < m_BiggestTick\n                    && (i % Mathf.RoundToInt(m_TickModulos[l + 1] / m_TickModulos[l]) == 0))\n                    continue;\n                list.Add(i * m_TickModulos[l]);\n            }\n        }\n\n        public float GetStrengthOfLevel(int level)\n        {\n            return m_TickStrengths[m_SmallestTick + level];","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Animation/TickHandler.cs#L135-L171","documentation":"Thrown by TickHandler.GetTicksAtLevel(int, bool, List<float>) when the caller-supplied list is null. The method populates the list in place (and the sibling overload returns an array); a null list cannot be added to, so the guard throws ArgumentNullException(nameof(list)) before the loop.","triggerScenarios":"Calling GetTicksAtLevel(level, exclude, null). Reusing a field that was cleared to null. Passing a List<float> pulled from a dictionary with TryGetValue that failed.","commonSituations":"Custom editor timeline/ruler drawing that reuses a tick list across repaints. Animation curve editor extensions. Tools that pool lists but occasionally null them out.","solutions":["Allocate the list before calling: new List<float>() or reuse a cleared instance.","If the array-returning overload fits, use GetTicksAtLevel(level, exclude) which handles its own list.","Pool and clear, but never null: list ??= new List<float>(); list.Clear();.","Validate at the call site and log the caller."],"exampleFix":"// before\nhandler.GetTicksAtLevel(level, false, null);\n\n// after\nvar ticks = new List<float>(64);\nhandler.GetTicksAtLevel(level, false, ticks);","handlingStrategy":"validation","validationCode":"list ??= new List<float>(); list.Clear();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Allocate the List<float> before calling GetTicksAtLevel.","Clear pooled lists instead of nulling them.","Prefer the array-returning overload when you do not need to reuse a list."],"tags":["animation","argument-null","editor","timeline","csharp"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}