{"record":{"id":"55b043b36a6bfb96","repo":"stride3d/stride","slug":"simulated-keyboard-does-not-exist","errorCode":null,"errorMessage":"Simulated Keyboard does not exist","messagePattern":"Simulated Keyboard does not exist","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Input/Simulated/InputSourceSimulated.cs","lineNumber":95,"sourceCode":"        public void RemoveAllMice()\n        {\n            foreach (var mouse in mice)\n                UnregisterDevice(mouse);\n            mice.Clear();\n        }\n\n        public KeyboardSimulated AddKeyboard()\n        {\n            var keyboard = new KeyboardSimulated(this);\n            keyboards.Add(keyboard);\n            RegisterDevice(keyboard);\n            return keyboard;\n        }\n\n        public void RemoveKeyboard(KeyboardSimulated keyboard)\n        {\n            if (!keyboards.Contains(keyboard))\n                throw new InvalidOperationException(\"Simulated Keyboard does not exist\");\n            UnregisterDevice(keyboard);\n            keyboards.Remove(keyboard);\n        }\n\n        public void RemoveAllKeyboards()\n        {\n            foreach (var keyboard in keyboards)\n                UnregisterDevice(keyboard);\n            keyboards.Clear();\n        }\n\n        public PointerSimulated AddPointer()\n        {\n            var pointer = new PointerSimulated(this);\n            pointers.Add(pointer);\n            RegisterDevice(pointer);\n            return pointer;\n        }","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Input/Simulated/InputSourceSimulated.cs#L77-L113","documentation":"InputSourceSimulated.RemoveKeyboard requires the KeyboardSimulated instance to be present in the source's keyboards collection. Passing an untracked or already-removed keyboard throws InvalidOperationException.","triggerScenarios":"Calling RemoveKeyboard with a keyboard not created by this source's CreateKeyboard, or calling RemoveKeyboard twice on the same instance.","commonSituations":"Repeated test teardown; keyboards removed via RemoveAllKeyboards and then removed again individually; cross-source keyboard references.","solutions":["Only remove keyboards created by this source","Guard against double removal with bookkeeping or membership checks","Use RemoveAllKeyboards for batch teardown","After removal, drop references so the instance isn't passed again"],"exampleFix":"// before\nsource.RemoveKeyboard(keyboard);\nsource.RemoveKeyboard(keyboard); // throws\n// after\nif (keyboards.Contains(keyboard)) source.RemoveKeyboard(keyboard);","handlingStrategy":"validation","validationCode":"if (createdKeyboards.Contains(keyboard)) source.RemoveKeyboard(keyboard);","typeGuard":null,"tryCatchPattern":"try { source.RemoveKeyboard(keyboard); } catch (InvalidOperationException) { /* already removed */ }","preventionTips":["Only remove keyboards created by this source instance","Clear references after removal","Use RemoveAllKeyboards for teardown"],"tags":["input","simulated","keyboard","entity-not-found"],"backgroundTag":"resource-not-found","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}