{"record":{"id":"9a9f6b8978f5cea1","repo":"stride3d/stride","slug":"corewindow","errorCode":null,"errorMessage":"coreWindow","messagePattern":"coreWindow","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Input/UWP/InputSourceUWP.cs","lineNumber":47,"sourceCode":"        private readonly CoreWindow coreWindow;\n        private WindowsAccelerometer windowsAccelerometer;\n        private WindowsCompass windowsCompass;\n        private WindowsGyroscope windowsGyroscope;\n        private WindowsOrientation windowsOrientation;\n\n        private AccelerometerSensor accelerometer;\n        private CompassSensor compass;\n        private GyroscopeSensor gyroscope;\n        private OrientationSensor orientation;\n        private GravitySensor gravity;\n        private UserAccelerationSensor userAcceleration;\n\n        private PointerUWP pointer;\n        private KeyboardUWP keyboard;\n\n        public InputSourceUWP(CoreWindow coreWindow)\n        {\n            this.coreWindow = coreWindow ?? throw new ArgumentNullException(nameof(coreWindow));\n        }\n\n        public override void Initialize(InputManager inputManager)\n        {\n            var mouseCapabilities = new MouseCapabilities();\n            if (mouseCapabilities.MousePresent > 0)\n            {\n                pointer = new MouseUWP(this, coreWindow);\n                RegisterDevice(pointer);\n            }\n\n            var keyboardCapabilities = new KeyboardCapabilities();\n            if (keyboardCapabilities.KeyboardPresent > 0)\n            {\n                keyboard = new KeyboardUWP(this, coreWindow);\n                RegisterDevice(keyboard);\n            }\n","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Input/UWP/InputSourceUWP.cs#L29-L65","documentation":"InputSourceUWP's constructor requires a valid UWP CoreWindow to attach input handlers to. If the coreWindow parameter is null, the constructor immediately throws ArgumentNullException via the null-coalescing throw expression. This library fails fast because an input source without a window cannot receive any pointer or keyboard events.","triggerScenarios":"Calling new InputSourceUWP(null) or passing a CoreWindow field/property that has not yet been initialized when constructing the input source.","commonSituations":"Setting up Stride input in a UWP app before Window.Current/CoreWindow is available (e.g. in a background thread or before activation completes); refactoring code so a window field is no longer assigned before the input source is created.","solutions":["Ensure the CoreWindow is obtained (CoreWindow.GetForCurrentThread()) on the UI thread before constructing InputSourceUWP.","Guard the construction site with a null check and defer input-source creation until the window is ready.","Run input source setup on the main/UI thread so the current CoreWindow is resolvable."],"exampleFix":"// before\nvar source = new InputSourceUWP(someWindowField);\n// after\nif (someWindowField == null)\n    throw new InvalidOperationException(\"InputSourceUWP requires an initialized CoreWindow; create it on the UI thread.\");\nvar source = new InputSourceUWP(CoreWindow.GetForCurrentThread());","handlingStrategy":"validation","validationCode":"if (coreWindow == null)\n    throw new InvalidOperationException(\"InputSourceUWP requires a CoreWindow; obtain it via CoreWindow.GetForCurrentThread() on the UI thread.\");\nvar source = new InputSourceUWP(coreWindow);","typeGuard":"bool HasCoreWindow(Windows.UI.Core.CoreWindow w) => w != null;","tryCatchPattern":"try\n{\n    var source = new InputSourceUWP(coreWindow);\n}\ncatch (ArgumentNullException)\n{\n    // Defer initialization until the UI thread provides a CoreWindow.\n}","preventionTips":["Create the input source on the UI thread only.","Assert the CoreWindow is resolved before input setup.","Never pass window fields that may be assigned lazily."],"tags":["uwp","null-argument","input"],"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"}