EllanJiang/GameFramework · error · GameFrameworkException
Resource extension is invalid.
Error message
Resource extension is invalid.
What it means
The ResourceName constructor throws this when the `extension` argument is null or empty. Every resource name must carry a non-empty extension (e.g. ".dat") so the ResourceManager can resolve the underlying file; the `variant` parameter is allowed to be empty but extension is not.
Solutions
- Pass a non-empty extension string (e.g. ".dat") when constructing ResourceName
- Fix the parsing code that strips the extension from the source path
- Verify version list / config data actually contains the extension for each resource
Example fix
// before
var name = new ResourceName("MyResource", variant, Path.GetFileNameWithoutExtension(path));
// after
var name = new ResourceName("MyResource", variant, Path.GetExtension(path)); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(extension)) throw new ArgumentException("Resource extension must be non-empty", nameof(extension)); Type guard
bool IsValidResourceExtension(string ext) => !string.IsNullOrEmpty(ext);
Try / catch
try { var rn = new ResourceName(name, variant, ext); } catch (GameFrameworkException ex) { Log.Error($"Invalid resource extension '{ext}': {ex.Message}"); } Prevention
- Keep the extension in your resource path data end-to-end
- Use Path.GetExtension rather than stripping extensions from parsed paths
- Assert extension presence in version-list/config loading code
When it happens
Trigger: Calling `new ResourceName(name, variant, null)` or `new ResourceName(name, variant, "")`, or passing a path whose extension was stripped/never captured by parsing code.
Common situations: Path parsing with Path.GetFileNameWithoutExtension losing the extension; version list data missing the extension field; hard-coded resource constructions that forgot the extension argument.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Resource name is invalid.
- Dependency assets is invalid.
- Resource is invalid.
- Resource helper is invalid.
- Resource loader is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/29c3dba42dbb81fe.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Resource/ResourceManager.ResourceName.cs:43
private readonly string m_Variant;
private readonly string m_Extension;
/// <summary>
/// 初始化资源名称的新实例。
/// </summary>
/// <param name="name">资源名称。</param>
/// <param name="variant">变体名称。</param>
/// <param name="extension">扩展名称。</param>
public ResourceName(string name, string variant, string extension)
{
if (string.IsNullOrEmpty(name))
{
throw new GameFrameworkException("Resource name is invalid.");
}
if (string.IsNullOrEmpty(extension))
{
throw new GameFrameworkException("Resource extension is invalid.");
}
m_Name = name;
m_Variant = variant;
m_Extension = extension;
}
/// <summary>
/// 获取资源名称。
/// </summary>
public string Name
{
get
{
return m_Name;
}
}
View on GitHub (pinned to d0c010b051)