{"record":{"id":"030a414791b27f96","repo":"stride3d/stride","slug":"uicontrol","errorCode":null,"errorMessage":"uiControl","messagePattern":"uiControl","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Input/Windows/InputSourceWindowsRawInput.cs","lineNumber":23,"sourceCode":"using System;\nusing System.Windows.Forms;\nusing SharpDX.Multimedia;\nusing SharpDX.RawInput;\nusing Stride.Games;\n\nnamespace Stride.Input\n{\n    /// <summary>\n    /// Provides support for raw keyboard input on windows\n    /// </summary>\n    internal class InputSourceWindowsRawInput : InputSourceBase\n    {\n        private readonly Control uiControl;\n        private KeyboardWindowsRawInput keyboard;\n\n        public InputSourceWindowsRawInput(Control uiControl)\n        {\n            this.uiControl = uiControl ?? throw new ArgumentNullException(nameof(uiControl));\n        }\n\n        public override void Initialize(InputManager inputManager)\n        {\n            keyboard = new KeyboardWindowsRawInput(this);\n            RegisterDevice(keyboard);\n            BindRawInputKeyboard(uiControl);\n        }\n\n        public override void Update()\n        {\n        }\n\n        public override void Dispose()\n        {\n            // Unregisters devices\n            base.Dispose();\n","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Input/Windows/InputSourceWindowsRawInput.cs#L5-L41","documentation":"InputSourceWindowsRawInput's constructor requires a WinForms Control to which raw input messages (WM_INPUT) are hooked. Passing a null uiControl throws ArgumentNullException immediately via the null-coalescing throw. Raw input cannot be registered without a window handle to receive messages.","triggerScenarios":"Calling new InputSourceWindowsRawInput(null) or passing a Control field that is not yet created.","commonSituations":"Headless/server-side instantiation where no WinForms UI exists; constructing the input source before the main form is created; refactoring where the form reference is assigned later.","solutions":["Create and show the main Form first, then construct InputSourceWindowsRawInput with it.","Verify the Control variable is assigned before constructing the input source.","Choose an input source appropriate for headless scenarios (or a non-RawInput backend) when no window exists."],"exampleFix":"// before\nvar source = new InputSourceWindowsRawInput(mainForm);\n// after\nif (mainForm == null || mainForm.IsDisposed)\n    throw new InvalidOperationException(\"Raw input requires a live WinForms control.\");\nvar source = new InputSourceWindowsRawInput(mainForm);","handlingStrategy":"validation","validationCode":"if (uiControl == null || uiControl.IsDisposed)\n    throw new InvalidOperationException(\"InputSourceWindowsRawInput requires a live WinForms control.\");\nvar source = new InputSourceWindowsRawInput(uiControl);","typeGuard":"bool HasLiveControl(Control c) => c != null && !c.IsDisposed && c.IsHandleCreated;","tryCatchPattern":"try\n{\n    var source = new InputSourceWindowsRawInput(uiControl);\n}\ncatch (ArgumentNullException)\n{\n    // Wait for form creation, then retry input initialization.\n}","preventionTips":["Initialize input sources after the main form is constructed.","Verify the control handle exists before raw-input registration.","Avoid constructing window-backed input sources in headless tests."],"tags":["winforms","raw-input","null-argument","windows"],"backgroundTag":"null-argument","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"}