{"record":{"id":"b6e3c4a073313109","repo":"stride3d/stride","slug":"is-not-a-supported-mode","errorCode":null,"errorMessage":" is not a supported mode.","messagePattern":" is not a supported mode\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core/Collections/SortedList.cs","lineNumber":785,"sourceCode":"\n        public object Current\n        {\n            get\n            {\n                if (invalid || pos >= size || pos == -1)\n                    throw new InvalidOperationException(xstr);\n\n                switch (mode)\n                {\n                    case EnumeratorMode.KEY_MODE:\n                        return currentKey;\n                    case EnumeratorMode.VALUE_MODE:\n                        return currentValue;\n                    case EnumeratorMode.ENTRY_MODE:\n                        return this.Entry;\n\n                    default:\n                        throw new NotSupportedException(mode + \" is not a supported mode.\");\n                }\n            }\n        }\n\n        // ICloneable\n\n        public object Clone()\n        {\n            var e = new DictionaryEnumerator(host, mode);\n            e.stamp = stamp;\n            e.pos = pos;\n            e.size = size;\n            e.currentKey = currentKey;\n            e.currentValue = currentValue;\n            e.invalid = invalid;\n            return e;\n        }\n    }","sourceCodeStart":767,"sourceCodeEnd":803,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core/Collections/SortedList.cs#L767-L803","documentation":"SortedList's internal enumerators use an EnumeratorMode (KEY_MODE/VALUE_MODE/ENTRY_MODE). Reading Current falls through to a default case that throws NotSupportedException when the mode is none of the known values. This is effectively an internal invariant violation: user code should never be able to set the mode directly.","triggerScenarios":"Reading Current from a SortedList enumerator whose _mode field holds a value outside KEY_MODE/VALUE_MODE/ENTRY_MODE — typically only via reflection, serialization of the enumerator, or memory/state corruption.","commonSituations":"Debugging tools or tests poking at enumerator internals; deserializing a captured enumerator object; custom derived code that assigned an invalid mode.","solutions":["Stop capturing/serializing enumerator objects; create a fresh enumerator via GetEnumerator() each time you iterate","Verify no reflection or derived-class code writes to the enumerator's mode field","Iterate with foreach or an explicitly typed interface (IDictionaryEnumerator/IEnumerator) so the correct mode is set by the library"],"exampleFix":"// before\nvar e = ((IEnumerable)sortedList).GetEnumerator();\nSerialize(e); // corrupts internal mode\n// after\nforeach (DictionaryEntry entry in sortedList) { /* use entry */ }","handlingStrategy":"try-catch","validationCode":"bool isEnumeratorValid(IEnumerator e) => e != null && (e.GetType().Name != \"SortedListEnumerator\" || IsKnownMode(e));","typeGuard":null,"tryCatchPattern":"try { var cur = enumerator.Current; } catch (NotSupportedException) { enumerator = sortedList.GetEnumerator(); }","preventionTips":["Never serialize, cache, or reflectively manipulate SortedList enumerators","Create a new enumerator per iteration pass","Iterate via foreach rather than raw IEnumerator"],"tags":["enumerator","notsupportedexception","sortedlist"],"backgroundTag":"unsupported-operation","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}