{"record":{"id":"1a80fb268b725eed","repo":"thebookisclosed/ViVe","slug":"variantpayloadkind-must-not-be-higher-than-3","errorCode":null,"errorMessage":"VariantPayloadKind must not be higher than 3.","messagePattern":"VariantPayloadKind must not be higher than 3\\.","errorType":"exception","errorClass":"FeaturePropertyOverflowException","httpStatus":null,"severity":"error","filePath":"ViVe/NativeStructs.cs","lineNumber":115,"sourceCode":"            }\n            set\n            {\n                if (value > 63)\n                    throw new FeaturePropertyOverflowException(\"Variant\", 63);\n                CompactState = (CompactState & 0xFFFFC0FF) | (value << 8);\n            }\n        }\n\n        public RTL_FEATURE_VARIANT_PAYLOAD_KIND VariantPayloadKind\n        {\n            get\n            {\n                return (RTL_FEATURE_VARIANT_PAYLOAD_KIND)((CompactState & 0xC000) >> 14);\n            }\n            set\n            {\n                if ((uint)value > 3)\n                    throw new FeaturePropertyOverflowException(\"VariantPayloadKind\", 3);\n                CompactState = (CompactState & 0xFFFF3FFF) | ((uint)value << 14);\n            }\n        }\n    }\n\n    [StructLayout(LayoutKind.Sequential)]\n    public struct RTL_FEATURE_USAGE_SUBSCRIPTION_DETAILS\n    {\n        public uint FeatureId;\n        public ushort ReportingKind;\n        public ushort ReportingOptions;\n        public ulong ReportingTarget;\n    }\n\n    [StructLayout(LayoutKind.Sequential)]\n    public struct RTL_FEATURE_CONFIGURATION_UPDATE\n    {\n        public uint FeatureId;","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/thebookisclosed/ViVe/blob/3f8c6a3425983412da1e8b26cd757c3aa17b3f25/ViVe/NativeStructs.cs#L97-L133","documentation":"VariantPayloadKind in RTL_FEATURE_CONFIGURATION is a 2-bit field (bits 14-15 of CompactState) with only values 0-3 defined (None, and the payload kinds). Assigning a cast value above 3 would corrupt the packed state, so the setter throws FeaturePropertyOverflowException(\"VariantPayloadKind\", 3).","triggerScenarios":"Assigning config.VariantPayloadKind = (RTL_FEATURE_VARIANT_PAYLOAD_KIND)rawValue where rawValue > 3.","commonSituations":"Decoding native/registry data without isolating bits 14-15; confusion with the Variant field's 6-bit range; using sentinel values not defined by the enum.","solutions":["Mask the raw value: (raw >> 14) & 0x3 before casting","Only assign defined RTL_FEATURE_VARIANT_PAYLOAD_KIND members (0-3)","Use VariantPayloadKind.None when no payload is intended"],"exampleFix":"// before\nconfig.VariantPayloadKind = (RTL_FEATURE_VARIANT_PAYLOAD_KIND)rawDword;\n// after\nconfig.VariantPayloadKind = (RTL_FEATURE_VARIANT_PAYLOAD_KIND)((rawDword >> 14) & 0x3);","handlingStrategy":"validation","validationCode":"uint k = (uint)kind;\nif (k > 3) throw new ArgumentOutOfRangeException(nameof(kind), \"VariantPayloadKind must be 0-3.\");\nconfig.VariantPayloadKind = (RTL_FEATURE_VARIANT_PAYLOAD_KIND)k;","typeGuard":"static bool IsValidVariantPayloadKind(uint v) => v <= 3;","tryCatchPattern":"try { config.VariantPayloadKind = kind; }\ncatch (FeaturePropertyOverflowException ex)\n{\n    // default to VariantPayloadKind.None or report decode failure\n}","preventionTips":["Mask decoded values: (raw >> 14) & 0x3","Only assign defined RTL_FEATURE_VARIANT_PAYLOAD_KIND members","Don't confuse the 2-bit kind field with the 6-bit Variant field"],"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"}