{"record":{"id":"621359481a23a522","repo":"stride3d/stride","slug":"activatedgestures-collection-was-modified-but-the-action-was","errorCode":null,"errorMessage":"ActivatedGestures collection was modified but the action was not supported by the system.","messagePattern":"ActivatedGestures collection was modified but the action was not supported by the system\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Input/InputManager.cs","lineNumber":748,"sourceCode":"            foreach (var source in Sources)\n            {\n                source.Dispose();\n            }\n        }\n\n        private void GesturesOnCollectionChanged(object sender, TrackingCollectionChangedEventArgs trackingCollectionChangedEventArgs)\n        {\n            switch (trackingCollectionChangedEventArgs.Action)\n            {\n                case NotifyCollectionChangedAction.Add:\n                    StartGestureRecognition((GestureConfig)trackingCollectionChangedEventArgs.Item);\n                    break;\n                case NotifyCollectionChangedAction.Remove:\n                    StopGestureRecognition((GestureConfig)trackingCollectionChangedEventArgs.Item);\n                    break;\n                case NotifyCollectionChangedAction.Replace:\n                case NotifyCollectionChangedAction.Reset:\n                    throw new NotSupportedException(\"ActivatedGestures collection was modified but the action was not supported by the system.\");\n                case NotifyCollectionChangedAction.Move:\n                    break;\n                default:\n                    throw new ArgumentOutOfRangeException();\n            }\n        }\n\n        private void StartGestureRecognition(GestureConfig config)\n        {\n            float aspectRatio = Pointer?.SurfaceAspectRatio ?? 1.0f; \n            gestureConfigToRecognizer.Add(config, config.CreateRecognizer(aspectRatio));\n        }\n\n        private void StopGestureRecognition(GestureConfig config)\n        {\n            gestureConfigToRecognizer.Remove(config);\n        }\n","sourceCodeStart":730,"sourceCodeEnd":766,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Input/InputManager.cs#L730-L766","documentation":"The ActivatedGestures collection only supports Add and Remove operations. Replace and Reset changes throw NotSupportedException because the gesture recognition pipeline cannot swap or clear gesture configurations atomically, and Move is ignored.","triggerScenarios":"Calling ActivatedGestures.Clear() (Reset), assigning a new gesture at an index (Replace), or bulk-replacing the collection contents after the manager is running.","commonSituations":"Trying to reset gesture settings between levels/screens by clearing the collection; swapping configurations in place; data-binding replacing the whole collection.","solutions":["Remove gesture configs individually with ActivatedGestures.Remove(g) instead of Clear().","Add new configs one by one with Add after removing the old ones.","Replace the whole gesture set only before the InputManager starts processing, or stop recognition first."],"exampleFix":"// before\ninput.ActivatedGestures.Clear();\n// after\nforeach (var g in input.ActivatedGestures.ToList())\n    input.ActivatedGestures.Remove(g);","handlingStrategy":"validation","validationCode":"// never call Clear(); remove items one by one\nforeach (var g in input.ActivatedGestures.ToList()) input.ActivatedGestures.Remove(g);","typeGuard":null,"tryCatchPattern":"try { gestures.Clear(); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"ActivatedGestures\"))\n{ foreach (var g in gestures.ToList()) gestures.Remove(g); }","preventionTips":["Treat ActivatedGestures as Add/Remove-only at runtime.","Never use Clear(), Replace or Move on the collection while running.","Configure the full gesture set before the game loop starts."],"tags":["input","gestures","unsupported-collection-operation"],"backgroundTag":"unsupported-enum-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}