{"record":{"id":"59116bb87ac54dfc","repo":"egametang/ET","slug":"type-fullname","errorCode":null,"errorMessage":"无法为类型 {type.FullName} 生成稳定排序键","messagePattern":"无法为类型 (.+?) 生成稳定排序键","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.config/Scripts/Model/Share/CSharpObjectCodeEmitter.cs","lineNumber":559,"sourceCode":"\n            info = null;\n            return false;\n        }\n\n        private string GetStableOrderKey(object value)\n        {\n            if (value == null)\n            {\n                return string.Empty;\n            }\n\n            Type type = value.GetType();\n            if (TryFormatInlineValue(type, value, out string inlineValue))\n            {\n                return inlineValue;\n            }\n\n            throw new NotSupportedException($\"无法为类型 {type.FullName} 生成稳定排序键\");\n        }\n\n        private bool TryFormatInlineValue(Type type, object value, out string code)\n        {\n            code = null;\n\n            if (value == null)\n            {\n                code = \"null\";\n                return true;\n            }\n\n            Type underlyingType = Nullable.GetUnderlyingType(type);\n            if (underlyingType != null)\n            {\n                return this.TryFormatInlineValue(underlyingType, value, out code);\n            }\n","sourceCodeStart":541,"sourceCodeEnd":577,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.config/Scripts/Model/Share/CSharpObjectCodeEmitter.cs#L541-L577","documentation":"Thrown when the emitter needs a stable string sort key for a value (used to produce deterministic output ordering) but the value's type cannot be formatted as an inline literal by TryFormatInlineValue. Only primitive/inline-formattable types yield a stable key; anything else is rejected so ordering never becomes non-deterministic.","triggerScenarios":"Passing a value of an unsupported type (custom struct/class, decimal in some paths, enum-with-custom-format, or any non-inline type) into a context where the emitter must derive a sort key (e.g. ordering dictionary keys / collection elements for stable emission).","commonSituations":"A config collection contains a custom value type used as a sort key; a new member type is introduced that the emitter's inline formatter does not recognize.","solutions":["Use an inline-formattable type (string, numeric primitive, enum, or a type already handled by TryFormatInlineValue) as the sort key.","Add a formatter branch in TryFormatInlineValue for the new type if it has a stable literal form.","Wrap the value in a comparable surrogate key (e.g. an int id) and sort by that instead."],"exampleFix":"// before\n// collection keyed/sorted by a custom struct\n// after\n// sort by a primitive id the emitter can format inline","handlingStrategy":"validation","validationCode":"// only use inline-formattable types as sort keys\nstatic bool IsInlineFormattable(Type t) =>\n    t.IsPrimitive || t == typeof(string) || t == typeof(decimal) || t.IsEnum;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use primitive/string/enum sort keys for collections handed to the emitter.","Extend TryFormatInlineValue when introducing a new inline-formattable value type.","Project custom-keyed data to an int/string surrogate before export."],"tags":["csharp","unity","config","serialization","code-emitter"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}