{"record":{"id":"8665ecb5712ef728","repo":"thebookisclosed/ViVe","slug":"enabledstateoptions-must-not-be-higher-than-1","errorCode":null,"errorMessage":"EnabledStateOptions must not be higher than 1.","messagePattern":"EnabledStateOptions must not be higher than 1\\.","errorType":"exception","errorClass":"FeaturePropertyOverflowException","httpStatus":null,"severity":"error","filePath":"ViVe/NativeStructs.cs","lineNumber":179,"sourceCode":"            }\n            set\n            {\n                if ((uint)value > 2)\n                    throw new FeaturePropertyOverflowException(\"EnabledState\", 2);\n                _enabledState = value;\n            }\n        }\n\n        public RTL_FEATURE_ENABLED_STATE_OPTIONS EnabledStateOptions\n        {\n            get\n            {\n                return _enabledStateOptions;\n            }\n            set\n            {\n                if ((uint)value > 1)\n                    throw new FeaturePropertyOverflowException(\"EnabledStateOptions\", 1);\n                _enabledStateOptions = value;\n            }\n        }\n\n        public uint Variant\n        {\n            get\n            {\n                return _variant;\n            }\n            set\n            {\n                if (value > 63)\n                    throw new FeaturePropertyOverflowException(\"Variant\", 63);\n                _variant = value;\n            }\n        }\n","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/thebookisclosed/ViVe/blob/3f8c6a3425983412da1e8b26cd757c3aa17b3f25/ViVe/NativeStructs.cs#L161-L197","documentation":"EnabledStateOptions in RTL_FEATURE_CONFIGURATION_UPDATE is a 1-bit option (valid values 0-1) that tells the native API whether to set or skip the EnabledState. Any value above 1 is invalid, so the setter throws FeaturePropertyOverflowException(\"EnabledStateOptions\", 1).","triggerScenarios":"Assigning update.EnabledStateOptions = (RTL_FEATURE_ENABLED_STATE_OPTIONS)value with value > 1, e.g. casting a multi-bit flags word into the property.","commonSituations":"OR-ing multiple flags together and assigning the combined word; copying an options field from a different struct/ABI with wider options; decoding raw memory without masking to one bit.","solutions":["Mask the value with & 0x1 before casting to RTL_FEATURE_ENABLED_STATE_OPTIONS","Assign only the defined enum members (e.g. DontSet / Set) instead of computed flag combinations","If you need to express several options, they belong in different fields, not combined into this 1-bit property"],"exampleFix":"// before\nupdate.EnabledStateOptions = (RTL_FEATURE_ENABLED_STATE_OPTIONS)(flagsA | flagsB); // may exceed 1\n// after\nupdate.EnabledStateOptions = ((uint)flagsA | flagsB) != 0 ? RTL_FEATURE_ENABLED_STATE_OPTIONS.Set : RTL_FEATURE_ENABLED_STATE_OPTIONS.DontSet;","handlingStrategy":"validation","validationCode":"uint o = (uint)options;\nif (o > 1) throw new ArgumentOutOfRangeException(nameof(options), \"EnabledStateOptions must be 0-1.\");\nupdate.EnabledStateOptions = (RTL_FEATURE_ENABLED_STATE_OPTIONS)o;","typeGuard":"static bool IsValidEnabledStateOptions(uint v) => v <= 1;","tryCatchPattern":"try { update.EnabledStateOptions = options; }\ncatch (FeaturePropertyOverflowException ex)\n{\n    // reduce to a single-bit decision: set or don't set\n}","preventionTips":["Treat it as a boolean, not a flags word","Never OR multiple values into it","Mask with & 0x1 when deriving from raw data"],"tags":["csharp","bitfield","enum","value-out-of-range"],"backgroundTag":"value-out-of-range","analyzedSha":"3f8c6a3425983412da1e8b26cd757c3aa17b3f25","analyzedAt":"2026-09-14T11:10:27.021Z","contentChangedAt":"2026-09-14T11:10:27.021Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}