egametang/ET · error

config singleton invalid: {configType.FullName}

Error message

config singleton invalid: {configType.FullName}

What it means

Thrown by LoadOneConfig when the created category object is not an ASingleton. The ET framework registers configs as singletons via World.ReplaceSingleton, so every code-config category must inherit ASingleton; if it only implements IConfig (or neither), it cannot be registered and the load aborts.

Source

Thrown at Packages/cn.etetet.loader/Scripts/Loader/Share/ConfigLoaderHelper.cs:145

            {
                throw new Exception($"unsupported config type: {configProcessAttribute.ConfigType} {configType.FullName}");
            }

            IConfigFactory factory = GetConfigFactory(configType, configFactories);
            object category = factory.Create();
            if (category == null)
            {
                throw new Exception($"config create failed: {configType.FullName}");
            }

            if (category.GetType() != configType)
            {
                throw new Exception($"config type mismatch: expect={configType.FullName} actual={category.GetType().FullName}");
            }

            if (category is not ASingleton singleton)
            {
                throw new Exception($"config singleton invalid: {configType.FullName}");
            }

            if (category is not IConfig iConfig)
            {
                throw new Exception($"config interface invalid: {configType.FullName}");
            }

            loadedConfigs.Add(configType, iConfig);
            return singleton;
        }

        private static string GetConfigGroup(MemberInfo factoryType)
        {
            ConfigGroupAttribute configGroupAttribute = factoryType.GetCustomAttribute<ConfigGroupAttribute>();
            return string.IsNullOrWhiteSpace(configGroupAttribute?.Name) ? ConfigGroupNames.Config : configGroupAttribute.Name;
        }

        private static IConfigFactory GetConfigFactory(Type configType, ConfigFactoryGroupCollection configFactories)

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Make the named config category derive from ASingleton (and still implement IConfig).
  2. Update the codegen template so all config categories inherit ASingleton.

Example fix

// before
public class MyConfigCategory : IConfig { ... }

// after
public class MyConfigCategory : ASingleton, IConfig { ... }
Defensive patterns

Strategy: validation

Type guard

static bool IsCodeConfigCategory(Type t) =>
    typeof(ASingleton).IsAssignableFrom(t) && typeof(IConfig).IsAssignableFrom(t);

Prevention

When it happens

Trigger: A config category class implements IConfig but does not derive from ASingleton. LoadOneConfig's 'is not ASingleton' pattern (line 143) catches this after the type-equality check passes.

Common situations: A hand-written config category omitted the ASingleton base class; a codegen template generated a plain class; a refactor moved the category off the singleton hierarchy.

Related errors


AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13). Data as JSON: /api/errors/0b1bcb2655343971. Report an issue: GitHub.