EllanJiang/GameFramework · error · GameFrameworkException
Results is invalid.
Error message
Results is invalid.
What it means
GetAllFileInfos fills the caller-supplied List<FileInfo> with every file stored in this FileSystem. The library throws GameFrameworkException("Results is invalid.") when the results reference is null, because there is no list to populate. Passing a valid, initialized list is a contract of the API.
Solutions
- Pass a non-null, pre-allocated List<FileInfo> instance: fileSystem.GetAllFileInfos(new List<FileInfo>());
- Ensure any field/variable holding the list is initialized before the call.
- Wrap the call in a null check or guard clause before invoking.
Example fix
// before List<FileInfo> results = null; fileSystem.GetAllFileInfos(results); // after List<FileInfo> results = new List<FileInfo>(); fileSystem.GetAllFileInfos(results);
Defensive patterns
Strategy: validation
Validate before calling
if (results == null) throw new ArgumentException("results must not be null", nameof(results));
fileSystem.GetAllFileInfos(results); Type guard
bool IsValidResults(System.Collections.Generic.List<FileInfo> results) => results != null;
Try / catch
try { fileSystem.GetAllFileInfos(results); } catch (GameFrameworkException ex) { Log.Error("GetAllFileInfos failed: {0}", ex.Message); } Prevention
- Always pass a freshly allocated List<FileInfo>.
- Null-check inputs at API boundaries in your own helpers.
- Never reuse a list variable that may have been set to null on dispose.
When it happens
Trigger: Calling GetAllFileInfos(null) on any FileSystem instance (Read, Write, or ReadWrite access).
Common situations: Caching the list in a field that was never initialized; a helper method forwarding a null list obtained from another component; refactoring that removed the `new List<FileInfo>()` allocation.
Related errors
- Results is invalid.
- Owner is invalid.
- Resource manager is invalid.
- Data provider helper is invalid.
- Type is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/cd5c22428e3d73c4.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/FileSystem/FileSystem.cs:301
FileInfo[] results = new FileInfo[m_FileDatas.Count];
foreach (KeyValuePair<string, int> fileData in m_FileDatas)
{
BlockData blockData = m_BlockDatas[fileData.Value];
results[index++] = new FileInfo(fileData.Key, GetClusterOffset(blockData.ClusterIndex), blockData.Length);
}
return results;
}
/// <summary>
/// 获取所有文件信息。
/// </summary>
/// <param name="results">获取的所有文件信息。</param>
public void GetAllFileInfos(List<FileInfo> results)
{
if (results == null)
{
throw new GameFrameworkException("Results is invalid.");
}
results.Clear();
foreach (KeyValuePair<string, int> fileData in m_FileDatas)
{
BlockData blockData = m_BlockDatas[fileData.Value];
results.Add(new FileInfo(fileData.Key, GetClusterOffset(blockData.ClusterIndex), blockData.Length));
}
}
/// <summary>
/// 检查是否存在指定文件。
/// </summary>
/// <param name="name">要检查的文件名称。</param>
/// <returns>是否存在指定文件。</returns>
public bool HasFile(string name)
{
if (string.IsNullOrEmpty(name))View on GitHub (pinned to d0c010b051)