{"record":{"id":"c551a46660e40e73","repo":"peass-ng/PEASS-ng","slug":"type-typeof-t-fullname-doesn-t-have-the-flag","errorCode":null,"errorMessage":"Type '{typeof(T).FullName}' doesn't have the 'Flags' attribute","messagePattern":"Type '(.+?)' doesn't have the 'Flags' attribute","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/TaskScheduler/EnumUtil.cs","lineNumber":14,"sourceCode":"﻿using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\n\nnamespace winPEAS.TaskScheduler\n{\n    internal static class EnumUtil\n    {\n        public static void CheckIsEnum<T>(bool checkHasFlags = false)\n        {\n            if (!typeof(T).IsEnum)\n                throw new ArgumentException($\"Type '{typeof(T).FullName}' is not an enum\");\n            if (checkHasFlags && !IsFlags<T>())\n                throw new ArgumentException($\"Type '{typeof(T).FullName}' doesn't have the 'Flags' attribute\");\n        }\n\n        public static bool IsFlags<T>() => Attribute.IsDefined(typeof(T), typeof(FlagsAttribute));\n\n        public static void CheckHasValue<T>(T value, string argName = null)\n        {\n            CheckIsEnum<T>();\n            if (IsFlags<T>())\n            {\n                var allFlags = 0L;\n                foreach (T flag in Enum.GetValues(typeof(T)))\n                    allFlags |= Convert.ToInt64(flag);\n                if ((allFlags & Convert.ToInt64(value)) != 0L)\n                    return;\n            }\n            else if (Enum.IsDefined(typeof(T), value))\n                return;\n            throw new InvalidEnumArgumentException(argName ?? \"value\", Convert.ToInt32(value), typeof(T));","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/TaskScheduler/EnumUtil.cs#L1-L32","documentation":"CheckIsEnum<T>(checkHasFlags: true) additionally throws ArgumentException when T is an enum but lacks the [Flags] attribute. It is a validation sentinel fired by bit-manipulation helpers (like BitPosition) that require a flags-style enum, so the at-fault input is a non-flags enum type argument.","triggerScenarios":"Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/EnumUtil.cs:14 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Decorate the enum type with the [Flags] attribute before using it with bit-operation helpers.","Only pass enums that are semantically bit masks (e.g. TaskRunFlags) to methods requiring flags.","Check Attribute.IsDefined(typeof(T), typeof(FlagsAttribute)) before calling when the flags requirement is uncertain."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}