{"record":{"id":"e7b13d40437ba789","repo":"egametang/ET","slug":"condition-variable-is-empty-type-fullname","errorCode":null,"errorMessage":"condition variable is empty: {type.FullName}","messagePattern":"condition variable is empty: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"Packages/cn.etetet.conditionexpr/Scripts/Model/Share/ConditionVariableRegistry.cs","lineNumber":31,"sourceCode":"        public void Awake()\n        {\n            this.RegisterNumericTypes();\n            \n            HashSet<Type> types = CodeTypes.Instance.GetTypes(typeof(ConditionVariableAttribute));\n            foreach (Type type in types)\n            {\n                if (!typeof(BTCondition).IsAssignableFrom(type))\n                {\n                    throw new Exception($\"condition variable node must inherit BTCondition: {type.FullName}\");\n                }\n\n                object[] attrs = type.GetCustomAttributes(typeof(ConditionVariableAttribute), false);\n                foreach (object attr in attrs)\n                {\n                    ConditionVariableAttribute conditionVariableAttribute = (ConditionVariableAttribute)attr;\n                    if (string.IsNullOrWhiteSpace(conditionVariableAttribute.Variable))\n                    {\n                        throw new Exception($\"condition variable is empty: {type.FullName}\");\n                    }\n\n                    if (!this.variableNodeTypes.TryAdd(conditionVariableAttribute.Variable, type))\n                    {\n                        throw new Exception($\"duplicate condition variable: {conditionVariableAttribute.Variable}\");\n                    }\n                }\n            }\n        }\n\n        private void RegisterNumericTypes()\n        {\n            foreach (NumericType numericType in Enum.GetValues(typeof(NumericType)))\n            {\n                string variable = numericType.ToString();\n                this.numericTypes.Add(variable, numericType);\n                this.variableNodeTypes.Add(variable, typeof(BTNumericCompare));\n            }","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.conditionexpr/Scripts/Model/Share/ConditionVariableRegistry.cs#L13-L49","documentation":"Thrown during ConditionVariableRegistry.Awake() when a [ConditionVariable] attribute on a scanned type has a null, empty, or whitespace Variable string. The variable name is the lookup key for the parser, so an empty one is unusable.","triggerScenarios":"Writing `[ConditionVariable(\"\")]` or `[ConditionVariable(\"   \")]`, or using the attribute's default constructor/field that leaves Variable unset.","commonSituations":"Typo when filling the attribute; copy-paste of a template with a placeholder; attribute refactored to take the name from another property that returns empty.","solutions":["Set a non-empty, trimmed Variable string on the attribute, e.g. `[ConditionVariable(\"HasBuff\")]`.","Add a unit test asserting every [ConditionVariable] in the assembly has a non-empty name."],"exampleFix":"// before\n[ConditionVariable(\"\")]\npublic class HasBuffNode : BTCondition { }\n// after\n[ConditionVariable(\"HasBuff\")]\npublic class HasBuffNode : BTCondition { }","handlingStrategy":"validation","validationCode":"foreach (Type t in CodeTypes.Instance.GetTypes(typeof(ConditionVariableAttribute)))\n{\n    foreach (ConditionVariableAttribute a in t.GetCustomAttributes(typeof(ConditionVariableAttribute), false))\n        Assert.IsFalse(string.IsNullOrWhiteSpace(a.Variable), $\"{t.FullName} has empty variable\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add a test that no [ConditionVariable] has an empty/whitespace Variable.","Use a code template/snippet that always fills the variable name.","Bikeshed-lint attribute arguments in CI."],"tags":["csharp","unity","conditionexpr","attribute","bootstrap","registration"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}