{"record":{"id":"b3648b81a77757e0","repo":"EllanJiang/GameFramework","slug":"type-name-is-invalid","errorCode":null,"errorMessage":"Type name is invalid.","messagePattern":"Type name is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Utility/Utility.Assembly.cs","lineNumber":79,"sourceCode":"                }\n\n                results.Clear();\n                foreach (System.Reflection.Assembly assembly in s_Assemblies)\n                {\n                    results.AddRange(assembly.GetTypes());\n                }\n            }\n\n            /// <summary>\n            /// 获取已加载的程序集中的指定类型。\n            /// </summary>\n            /// <param name=\"typeName\">要获取的类型名。</param>\n            /// <returns>已加载的程序集中的指定类型。</returns>\n            public static Type GetType(string typeName)\n            {\n                if (string.IsNullOrEmpty(typeName))\n                {\n                    throw new GameFrameworkException(\"Type name is invalid.\");\n                }\n\n                Type type = null;\n                if (s_CachedTypes.TryGetValue(typeName, out type))\n                {\n                    return type;\n                }\n\n                type = Type.GetType(typeName);\n                if (type != null)\n                {\n                    s_CachedTypes.Add(typeName, type);\n                    return type;\n                }\n\n                foreach (System.Reflection.Assembly assembly in s_Assemblies)\n                {\n                    type = Type.GetType(Text.Format(\"{0}, {1}\", typeName, assembly.FullName));","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Utility/Utility.Assembly.cs#L61-L97","documentation":"Utility.Assembly.GetType looks up a type by name among registered assemblies, using a cache. The type name is required, and this exception is thrown when the supplied name is null or the empty string.","triggerScenarios":"Calling Utility.Assembly.GetType(null) or GetType(\"\"); passing a config-loaded type name that failed to deserialize into a non-empty string.","commonSituations":"Data-table/procedure type names read from config where the field is missing; string.Split or parsing producing an empty string; renamed type entries left blank in configuration.","solutions":["Validate the type name is non-empty before calling GetType","Fix the configuration/data source that produced the blank name","Check upstream string parsing (Split, Substring) that may yield an empty string","Add a null/empty guard or default value at the config-loading boundary"],"exampleFix":"// before\nstring typeName = config.TypeName; // may be \"\"\nType t = Utility.Assembly.GetType(typeName);\n// after\nif (string.IsNullOrEmpty(config.TypeName)) throw new ArgumentException(\"TypeName missing in config\");\nType t = Utility.Assembly.GetType(config.TypeName);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(typeName)) throw new ArgumentException(\"typeName is required\", nameof(typeName));","typeGuard":"bool IsValidTypeName(string typeName) => !string.IsNullOrEmpty(typeName);","tryCatchPattern":"try { var t = Utility.Assembly.GetType(typeName); } catch (GameFrameworkException ex) { Log.Error($\"Invalid type name '{typeName}'\"); }","preventionTips":["Validate config fields for non-empty type names at load time","Check string parsing/splitting that may yield empty results","Provide defaults for optional type-name config entries"],"tags":["reflection","validation","empty-string"],"backgroundTag":"empty-required-field","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}