{"record":{"id":"9bd364823e9598f7","repo":"thebookisclosed/ViVe","slug":"priority-must-not-be-higher-than-15","errorCode":null,"errorMessage":"Priority must not be higher than 15.","messagePattern":"Priority must not be higher than 15\\.","errorType":"exception","errorClass":"FeaturePropertyOverflowException","httpStatus":null,"severity":"error","filePath":"ViVe/NativeStructs.cs","lineNumber":49,"sourceCode":"    }\n\n    [StructLayout(LayoutKind.Sequential)]\n    public struct RTL_FEATURE_CONFIGURATION\n    {\n        public uint FeatureId;\n        public uint CompactState;\n        public uint VariantPayload;\n\n        public RTL_FEATURE_CONFIGURATION_PRIORITY Priority\n        {\n            get\n            {\n                return (RTL_FEATURE_CONFIGURATION_PRIORITY)(CompactState & 0xF);\n            }\n            set\n            {\n                if ((uint)value > 15)\n                    throw new FeaturePropertyOverflowException(\"Priority\", 15);\n                CompactState = (CompactState & 0xFFFFFFF0) | (uint)value;\n            }\n        }\n\n        public RTL_FEATURE_ENABLED_STATE EnabledState\n        {\n            get\n            {\n                return (RTL_FEATURE_ENABLED_STATE)((CompactState & 0x30) >> 4);\n            }\n            set\n            {\n                if ((uint)value > 2)\n                    throw new FeaturePropertyOverflowException(\"EnabledState\", 2);\n                CompactState = (CompactState & 0xFFFFFFCF) | ((uint)value << 4);\n            }\n        }\n","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/thebookisclosed/ViVe/blob/3f8c6a3425983412da1e8b26cd757c3aa17b3f25/ViVe/NativeStructs.cs#L31-L67","documentation":"The Priority property of RTL_FEATURE_CONFIGURATION is stored in the low 4 bits of a packed uint (CompactState & 0xF), so it can only hold values 0-15. Assigning anything larger would silently corrupt adjacent packed fields, so the setter throws FeaturePropertyOverflowException (a Feature \"Priority\" overflow, max 15).","triggerScenarios":"Assigning a Priority value greater than 15 (e.g. an arbitrary int/enum cast) to an RTL_FEATURE_CONFIGURATION instance, e.g. config.Priority = (RTL_FEATURE_CONFIGURATION_PRIORITY)someRawValue.","commonSituations":"Parsing raw registry/native memory into the enum without masking to 4 bits; off-by-shift errors when decoding packed configurations; using an enum value from a different feature-configuration ABI version.","solutions":["Mask the raw value with & 0xF before casting to RTL_FEATURE_CONFIGURATION_PRIORITY","Validate the value is <= 15 before assignment","If the source data legitimately holds a larger number, you are decoding the wrong field or ABI layout"],"exampleFix":"// before\nconfig.Priority = (RTL_FEATURE_CONFIGURATION_PRIORITY)rawDword;\n// after\nconfig.Priority = (RTL_FEATURE_CONFIGURATION_PRIORITY)(rawDword & 0xF);","handlingStrategy":"validation","validationCode":"uint p = (uint)rawPriority;\nif (p > 15) throw new ArgumentOutOfRangeException(nameof(rawPriority), \"Priority must be 0-15.\");\nconfig.Priority = (RTL_FEATURE_CONFIGURATION_PRIORITY)p;","typeGuard":"static bool IsValidPriority(uint v) => v <= 15;","tryCatchPattern":"try { config.Priority = value; }\ncatch (FeaturePropertyOverflowException ex)\n{\n    // clamp, mask, or report; ex names the property (Priority) and max (15)\n}","preventionTips":["Mask any raw/decoded value with & 0xF before casting","Only assign named enum members","Never derive priorities by arithmetic on other values without clamping"],"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"}