{"record":{"id":"8d7e569a4fffa1d6","repo":"thebookisclosed/ViVe","slug":"operation-must-not-be-higher-than-4","errorCode":null,"errorMessage":"Operation must not be higher than 4.","messagePattern":"Operation must not be higher than 4\\.","errorType":"exception","errorClass":"FeaturePropertyOverflowException","httpStatus":null,"severity":"error","filePath":"ViVe/NativeStructs.cs","lineNumber":221,"sourceCode":"            }\n            set\n            {\n                if ((uint)value > 3)\n                    throw new FeaturePropertyOverflowException(\"VariantPayloadKind\", 3);\n                _variantPayloadKind = value;\n            }\n        }\n\n        public RTL_FEATURE_CONFIGURATION_OPERATION Operation\n        {\n            get\n            {\n                return _operation;\n            }\n            set\n            {\n                if ((uint)value > 4)\n                    throw new FeaturePropertyOverflowException(\"Operation\", 4);\n                _operation = value;\n            }\n        }\n\n        public bool UserPolicyPriorityCompatible\n        {\n            get\n            {\n                return !((uint)EnabledStateOptions != 0 || _variant != 0 || (uint)_variantPayloadKind != 0 || VariantPayload != 0);\n            }\n        }\n    }\n}\n","sourceCodeStart":203,"sourceCodeEnd":235,"githubUrl":"https://github.com/thebookisclosed/ViVe/blob/3f8c6a3425983412da1e8b26cd757c3aa17b3f25/ViVe/NativeStructs.cs#L203-L235","documentation":"The RTL_FEATURE_CONFIGURATION_UPDATE struct's Operation setter validates that the RTL_FEATURE_CONFIGURATION_OPERATION value fits in the 3 bits the native RTL_FEATURE_CONFIGURATION structure reserves for it. Assigning a value numerically greater than 4 (the highest defined operation) throws FeaturePropertyOverflowException so an invalid operation never reaches the native feature configuration APIs, where it would be truncated or rejected as an unsupported operation.","triggerScenarios":"Setting the Operation property on RTL_FEATURE_CONFIGURATION_UPDATE to a value > 4, e.g. struct.Operation = (RTL_FEATURE_CONFIGURATION_OPERATION)5, or assigning an integer parsed from user input/configuration, or an enum value introduced by a newer/foreign SDK definition that exceeds the 3-bit field.","commonSituations":"Casting unvalidated command-line or config values into RTL_FEATURE_CONFIGURATION_OPERATION; copying an operation enum from a different Windows build where new operations were appended past the 3-bit storage; off-by-one arithmetic (Operation + 1) when sequencing feature configuration updates.","solutions":["Use only defined RTL_FEATURE_CONFIGURATION_OPERATION members (0-4); validate any parsed integer is <= 4 before casting.","Check the enum definition in your ViVe/SDK version for the exact set of valid operations.","Guard the assignment with an explicit range check or wrap it in try-catch on FeaturePropertyOverflowException.","Update the library/package if you legitimately need an operation value newer than this build supports."],"exampleFix":"// before\nconfig.Operation = (RTL_FEATURE_CONFIGURATION_OPERATION)opValue; // throws if opValue > 4\n\n// after\nif ((uint)opValue > 4)\n    throw new ArgumentOutOfRangeException(nameof(opValue), \"Operation must be 0-4\");\nconfig.Operation = (RTL_FEATURE_CONFIGURATION_OPERATION)opValue;","handlingStrategy":"validation","validationCode":"public static bool IsValidOperation(RTL_FEATURE_CONFIGURATION_OPERATION op) =>\n    (uint)op <= 4;","typeGuard":"public static bool IsDefinedOperation(RTL_FEATURE_CONFIGURATION_OPERATION op) =>\n    Enum.IsDefined(typeof(RTL_FEATURE_CONFIGURATION_OPERATION), op) && (uint)op <= 4;","tryCatchPattern":"try\n{\n    config.Operation = op;\n}\ncatch (FeaturePropertyOverflowException ex)\n{\n    // ex.Property == \"Operation\", max 4\n    throw new InvalidOperationException($\"Invalid Operation '{op}': must be 0-4.\", ex);\n}","preventionTips":["Use only named RTL_FEATURE_CONFIGURATION_OPERATION members; never cast unchecked integers.","Clamp or reject user/config-supplied operation codes to 0-4 before assignment.","Re-check enum definitions when upgrading Windows SDK or ViVe versions.","Cover each operation your application issues with tests so an out-of-range value surfaces in CI."],"tags":["csharp","value-out-of-range","enum","pinvoke","windows-features"],"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"}