EllanJiang/GameFramework · error · GameFrameworkException

Results is invalid.

Error message

Results is invalid.

What it means

GetDataRows(Predicate<T>, List<T>) validates its output List<T> parameter after checking the condition; a null results list throws GameFrameworkException("Results is invalid.") at line 206. The list is used as a caller-provided buffer that the method clears and fills.

Solutions

  1. Pass an instantiated List<T>: `new List<T>()` (or a pooled instance)
  2. Guard: `buffer ??= new List<T>();` before the call
  3. If the buffer is lazily created, ensure initialization happens before the first query
  4. Catch GameFrameworkException if the list comes from an external caller

Example fix

// before
List<MyRow> buffer = null;
table.GetDataRows(cond, buffer);
// after
List<MyRow> buffer = new List<MyRow>();
table.GetDataRows(cond, buffer);
Defensive patterns

Strategy: validation

Validate before calling

results ??= new List<T>();
dataTable.GetDataRows(condition, results);

Type guard

static bool BufferReady<T>(List<T> list) => list != null;

Try / catch

try { dataTable.GetDataRows(condition, results); }
catch (GameFrameworkException ex) when (ex.Message == "Results is invalid.") { results = new List<T>(); dataTable.GetDataRows(condition, results); }

Prevention

When it happens

Trigger: Calling GetDataRows(condition, null) — e.g. forgetting to new up the list, or passing a property that returns null before lazy initialization.

Common situations: Object-pool reuse code where the buffer field is assigned in OnEnable but the query runs earlier; a caller method with an optional list parameter defaulted to null.

Related errors


AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15). Data as JSON: /api/errors/b342b1bc632cd4a1. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/DataTable/DataTableManager.DataTable.cs:206

                return results.ToArray();
            }

            /// <summary>
            /// 获取符合条件的数据表行。
            /// </summary>
            /// <param name="condition">要检查的条件。</param>
            /// <param name="results">符合条件的数据表行。</param>
            public void GetDataRows(Predicate<T> condition, List<T> results)
            {
                if (condition == null)
                {
                    throw new GameFrameworkException("Condition is invalid.");
                }

                if (results == null)
                {
                    throw new GameFrameworkException("Results is invalid.");
                }

                results.Clear();
                foreach (KeyValuePair<int, T> dataRow in m_DataSet)
                {
                    if (condition(dataRow.Value))
                    {
                        results.Add(dataRow.Value);
                    }
                }
            }

            /// <summary>
            /// 获取排序后的数据表行。
            /// </summary>
            /// <param name="comparison">要排序的条件。</param>
            /// <returns>排序后的数据表行。</returns>
            public T[] GetDataRows(Comparison<T> comparison)

View on GitHub (pinned to d0c010b051)